diff --git a/app/presenters/content_item/manual_section.rb b/app/presenters/content_item/manual_section.rb index d67b2061f..938a27eba 100644 --- a/app/presenters/content_item/manual_section.rb +++ b/app/presenters/content_item/manual_section.rb @@ -20,11 +20,13 @@ def breadcrumb end def manual_content_item - # TODO: Add the same tagging to a normal section as a manual for contextual breadcrumbs - # 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 parsed_content_item + manual_content_item.parsed_content + end + def published display_date(manual_content_item["first_published_at"]) end diff --git a/app/presenters/content_item_presenter.rb b/app/presenters/content_item_presenter.rb index fd2a68232..51b96526a 100644 --- a/app/presenters/content_item_presenter.rb +++ b/app/presenters/content_item_presenter.rb @@ -36,6 +36,10 @@ def initialize(content_item, requested_path, view_context) @part_slug = requesting_a_part? ? requested_path.split("/").last : nil end + def parsed_content_item + content_item.parsed_content + end + def requesting_a_part? false end diff --git a/app/presenters/hmrc_manual_section_presenter.rb b/app/presenters/hmrc_manual_section_presenter.rb index db2e1b16c..47d72df00 100644 --- a/app/presenters/hmrc_manual_section_presenter.rb +++ b/app/presenters/hmrc_manual_section_presenter.rb @@ -7,10 +7,6 @@ def base_path details["manual"]["base_path"] end - def title - details["manual"]["title"] - end - def breadcrumbs crumbs = manual_breadcrumbs.dup @@ -85,6 +81,10 @@ def adjacent_siblings [before.try(:last), after.try(:first)] end + def manual + parent_base_path == base_path ? parent_for_section : manual_content_item + end + def parent_base_path content_item_breadcrumbs.present? ? content_item_breadcrumbs.last["base_path"] : base_path end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 6f206e855..8365fdb16 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -42,9 +42,7 @@ <%= render 'govuk_publishing_components/components/breadcrumbs', breadcrumbs: [ { url: "/", title: "Home" } , { url: "/brexit", title: "Brexit" } ] %> <% else %> - - <%= render 'govuk_publishing_components/components/contextual_breadcrumbs', - content_item: @content_item.try(:manual_content_item) || @content_item.content_item.parsed_content %> + <%= render 'govuk_publishing_components/components/contextual_breadcrumbs', content_item: @content_item.parsed_content_item %> <% end %> <% end %> diff --git a/test/presenters/hmrc_manual_section_presenter_test.rb b/test/presenters/hmrc_manual_section_presenter_test.rb index 44a111460..9227b7541 100644 --- a/test/presenters/hmrc_manual_section_presenter_test.rb +++ b/test/presenters/hmrc_manual_section_presenter_test.rb @@ -34,7 +34,10 @@ class PresentedHmrcManualSectionTest < HmrcManualSectionPresenterTestCase end test "presents manual title" do - manual = schema_item("vatgpb2000")["details"]["manual"] + manual_base_path = schema_item("vatgpb2000")["details"]["manual"]["base_path"] + manual = schema_item("vat-government-public-bodies", "hmrc_manual") + stub_content_store_has_item(manual_base_path, manual.to_json) + assert_equal manual["title"], presented_manual_section.title end