Skip to content

Commit

Permalink
Use manual timestamps for manual section header
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
1pretz1 committed May 17, 2022
1 parent 3e952b5 commit f7f1ea0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/presenters/content_item/manual.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions app/presenters/content_item/manual_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion test/integration/hmrc_manual_section_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down
23 changes: 23 additions & 0 deletions test/integration/manual_section_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f7f1ea0

Please sign in to comment.