From f7f1ea03a5d3fa66e6930bea108b4dd7c211ff92 Mon Sep 17 00:00:00 2001 From: Peter Hartshorn Date: Tue, 17 May 2022 16:20:38 +0100 Subject: [PATCH] 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. --- app/presenters/content_item/manual.rb | 6 ++++- app/presenters/content_item/manual_section.rb | 9 ++++++++ test/integration/hmrc_manual_section_test.rb | 2 +- test/integration/manual_section_test.rb | 23 +++++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/app/presenters/content_item/manual.rb b/app/presenters/content_item/manual.rb index 111a4182a..2b9a41893 100644 --- a/app/presenters/content_item/manual.rb +++ b/app/presenters/content_item/manual.rb @@ -51,8 +51,12 @@ def manual_metadata private def other_metadata + updated_metadata(public_updated_at) + end + + def updated_metadata(updated_at) updates_link = view_context.link_to(I18n.t("manuals.see_all_updates"), "#{base_path}/updates") - { I18n.t("manuals.updated") => "#{display_date(public_updated_at)}, #{updates_link}" } + { I18n.t("manuals.updated") => "#{display_date(updated_at)}, #{updates_link}" } end def details diff --git a/app/presenters/content_item/manual_section.rb b/app/presenters/content_item/manual_section.rb index a1ba6063b..ab8c2c2ed 100644 --- a/app/presenters/content_item/manual_section.rb +++ b/app/presenters/content_item/manual_section.rb @@ -22,7 +22,16 @@ def breadcrumb def manual_content_item # TODO: Add the same tagging to a normal section as a manual for contextual breadcrumbs # TODO: Add the manual title to the HMRC section content item and then we can remove this request (manual_content_item) + # TODO: Add the manual published / public updated at to both manual sections (normal and HMRC) @manual_content_item ||= Services.content_store.content_item(base_path) end + + def published + display_date(manual_content_item["first_published_at"]) + end + + def other_metadata + updated_metadata(manual_content_item["public_updated_at"]) + end end end diff --git a/test/integration/hmrc_manual_section_test.rb b/test/integration/hmrc_manual_section_test.rb index 1c7eaf0ea..532e6d7c3 100644 --- a/test/integration/hmrc_manual_section_test.rb +++ b/test/integration/hmrc_manual_section_test.rb @@ -18,7 +18,7 @@ class HmrcManualSectionTest < ActionDispatch::IntegrationTest assert_has_metadata( { from: { "HM Revenue & Customs": "/government/organisations/hm-revenue-customs" }, - first_published: "10 February 2015", + first_published: "11 February 2015", other: { I18n.t("manuals.see_all_updates") => "#{@manual['base_path']}/updates", }, diff --git a/test/integration/manual_section_test.rb b/test/integration/manual_section_test.rb index fff462619..7a1d46dfc 100644 --- a/test/integration/manual_section_test.rb +++ b/test/integration/manual_section_test.rb @@ -17,6 +17,29 @@ class ManualSectionTest < ActionDispatch::IntegrationTest end end + test "renders metadata" do + setup_and_visit_manual_section + + assert_has_metadata( + { + from: { "Government Digital Service": "/government/organisations/government-digital-service" }, + first_published: "27 April 2015", + other: { + I18n.t("manuals.see_all_updates") => "#{@manual['base_path']}/updates", + }, + }, + extra_metadata_classes: ".gem-c-metadata--inverse", + ) + end + + test "renders search box" do + setup_and_visit_manual_section + + within ".gem-c-search" do + assert page.has_text?(I18n.t("manuals.search_this_manual")) + end + end + test "renders document heading" do setup_and_visit_manual_section