-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1339 from DFE-Digital/ER-1219-add-updated-and-pub…
…lished-date Er 1219 add updated and published date
- Loading branch information
Showing
18 changed files
with
177 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
.timestamp { | ||
background: govuk-colour('light-grey'); | ||
padding: govuk-spacing(3) govuk-spacing(2) govuk-spacing(3) govuk-spacing(4); | ||
margin-top: 60px; | ||
border-left: govuk-spacing(1) solid govuk-organisation-colour('department-for-education'); | ||
|
||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
font-weight: 400; | ||
font-size: 14px; | ||
font-size: .875rem; | ||
line-height: 1.1429; | ||
|
||
@include govuk-media-query($from: tablet) { | ||
font-size:16px; | ||
font-size: 1rem; | ||
line-height: 1.25; | ||
|
||
a { | ||
font-family: sans-serif; | ||
} | ||
} | ||
|
||
a { | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
text-decoration: underline; | ||
font-weight: bold; | ||
color: govuk-colour('black'); | ||
} | ||
|
||
&.timestamp::after { | ||
content: ''; | ||
display: block; | ||
clear: both; | ||
} | ||
|
||
&__toggle-wrap { | ||
display: none; | ||
} | ||
|
||
dl { | ||
margin: 0; | ||
} | ||
|
||
dt { | ||
box-sizing: border-box; | ||
float: left; | ||
clear: left; | ||
padding-right: 5px; | ||
margin-top: 0; | ||
} | ||
|
||
dd { | ||
margin: 0; | ||
} | ||
} | ||
|
||
.timestamp .timestamp__definition-link { | ||
font-weight: normal; | ||
} | ||
|
||
@media print { | ||
.timestamp { | ||
color: govuk-colour('black'); | ||
font-family: sans-serif; | ||
font-size: 14pt; | ||
line-height: 1.2; | ||
} | ||
} | ||
|
||
.js-enabled { | ||
.timestamp__toggle-wrap { | ||
display: block; | ||
} | ||
|
||
.timestamp__toggle-items { | ||
.js-hidden { | ||
display: none; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
module DateHelper | ||
# @param datetime [DateTime] | ||
# @return [String] | ||
def certificate_date(datetime) | ||
def format_date(datetime) | ||
datetime.to_date.strftime('%-d %B %Y') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
- if !content.published_at.nil? | ||
.timestamp | ||
dl | ||
dt Published: | ||
dd = format_date(content.published_at) | ||
- if content.edited? | ||
dt Updated: | ||
dd = format_date(content.updated_at) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,5 @@ | |
.govuk-button-group | ||
= link_to_previous | ||
= link_to_next | ||
|
||
= render 'timestamp' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
h1.govuk-heading-l= content.heading | ||
|
||
= m(content.body) | ||
= render 'timestamp' | ||
|
||
= render 'debug' | ||
= render 'content' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
| Transcript | ||
|
||
= m(content.transcript) | ||
= render 'timestamp' | ||
|
||
= render 'debug' | ||
= render 'content' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
require 'rails_helper' | ||
|
||
describe 'DateHelper' do | ||
describe '#certificate_date' do | ||
describe '#format_date' do | ||
let(:input) { Time.zone.local(2001, 2, 3, 4, 5, 6) } | ||
|
||
it 'returns date in format "Day(in numbers) Month(in words) Year(in numbers)" format' do | ||
expect(helper.certificate_date(input)).to eq '3 February 2001' | ||
expect(helper.format_date(input)).to eq '3 February 2001' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
RSpec.shared_examples 'updated content' do |name| | ||
let(:mod) { Training::Module.by_name(:alpha) } | ||
let(:content) { mod.page_by_name(name) } | ||
|
||
describe '#edited?' do | ||
context 'when preview' do | ||
# make Rails.application.preview? return true | ||
it do | ||
allow(Rails.application).to receive(:preview?).and_return(true) | ||
expect(content).to be_edited unless content.content_type.id.eql?('video') | ||
end | ||
end | ||
|
||
context 'when delivery' do | ||
it do | ||
create(:module_release, first_published_at: Time.zone.local(2023, 1, 1)) | ||
expect(content).to be_edited | ||
end | ||
|
||
it do | ||
create(:module_release, first_published_at: Time.zone.local(3_099, 1, 1)) | ||
expect(content).not_to be_edited | ||
end | ||
end | ||
end | ||
|
||
describe '#published_at' do | ||
context 'when unpublished' do | ||
it do | ||
expect(content.published_at).to be_nil | ||
end | ||
end | ||
|
||
context 'when published' do | ||
before do | ||
create(:module_release, first_published_at: Time.zone.local(2023, 1, 1)) | ||
end | ||
|
||
it do | ||
expect(content.published_at.to_s).to eq '2023-01-01 00:00:00 UTC' | ||
end | ||
end | ||
end | ||
end |