Skip to content

Commit f7f1ea0

Browse files
committed
Use manual timestamps for manual section header
Currently (in Government Frontend) , a manual section's timestamps for published at and last updated at originate from the manual section. However, the live version (Manuals Frontend) uses the parents manual timestamps. This commit applies parent manuals timestamps as we should keep the behaviour the same. Also adds missing tests for a normal manual section.
1 parent 3e952b5 commit f7f1ea0

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

app/presenters/content_item/manual.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ def manual_metadata
5151
private
5252

5353
def other_metadata
54+
updated_metadata(public_updated_at)
55+
end
56+
57+
def updated_metadata(updated_at)
5458
updates_link = view_context.link_to(I18n.t("manuals.see_all_updates"), "#{base_path}/updates")
55-
{ I18n.t("manuals.updated") => "#{display_date(public_updated_at)}, #{updates_link}" }
59+
{ I18n.t("manuals.updated") => "#{display_date(updated_at)}, #{updates_link}" }
5660
end
5761

5862
def details

app/presenters/content_item/manual_section.rb

+9
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,16 @@ def breadcrumb
2222
def manual_content_item
2323
# TODO: Add the same tagging to a normal section as a manual for contextual breadcrumbs
2424
# TODO: Add the manual title to the HMRC section content item and then we can remove this request (manual_content_item)
25+
# TODO: Add the manual published / public updated at to both manual sections (normal and HMRC)
2526
@manual_content_item ||= Services.content_store.content_item(base_path)
2627
end
28+
29+
def published
30+
display_date(manual_content_item["first_published_at"])
31+
end
32+
33+
def other_metadata
34+
updated_metadata(manual_content_item["public_updated_at"])
35+
end
2736
end
2837
end

test/integration/hmrc_manual_section_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class HmrcManualSectionTest < ActionDispatch::IntegrationTest
1818
assert_has_metadata(
1919
{
2020
from: { "HM Revenue & Customs": "/government/organisations/hm-revenue-customs" },
21-
first_published: "10 February 2015",
21+
first_published: "11 February 2015",
2222
other: {
2323
I18n.t("manuals.see_all_updates") => "#{@manual['base_path']}/updates",
2424
},

test/integration/manual_section_test.rb

+23
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,29 @@ class ManualSectionTest < ActionDispatch::IntegrationTest
1717
end
1818
end
1919

20+
test "renders metadata" do
21+
setup_and_visit_manual_section
22+
23+
assert_has_metadata(
24+
{
25+
from: { "Government Digital Service": "/government/organisations/government-digital-service" },
26+
first_published: "27 April 2015",
27+
other: {
28+
I18n.t("manuals.see_all_updates") => "#{@manual['base_path']}/updates",
29+
},
30+
},
31+
extra_metadata_classes: ".gem-c-metadata--inverse",
32+
)
33+
end
34+
35+
test "renders search box" do
36+
setup_and_visit_manual_section
37+
38+
within ".gem-c-search" do
39+
assert page.has_text?(I18n.t("manuals.search_this_manual"))
40+
end
41+
end
42+
2043
test "renders document heading" do
2144
setup_and_visit_manual_section
2245

0 commit comments

Comments
 (0)