diff --git a/app/controllers/content_items_controller.rb b/app/controllers/content_items_controller.rb index 3dcbd998d..e09d428d1 100644 --- a/app/controllers/content_items_controller.rb +++ b/app/controllers/content_items_controller.rb @@ -87,7 +87,6 @@ def set_guide_draft_access_token def load_content_item content_item = Services.content_store.content_item(content_item_path) - if Services.feature_toggler.use_recommended_related_links?(content_item["links"], request.headers) content_item["links"]["ordered_related_items"] = content_item["links"].fetch("suggested_ordered_related_items", []) end diff --git a/app/presenters/content_item/brexit_hub_page.rb b/app/presenters/content_item/brexit_hub_page.rb new file mode 100644 index 000000000..e52737b3b --- /dev/null +++ b/app/presenters/content_item/brexit_hub_page.rb @@ -0,0 +1,26 @@ +module ContentItem + module BrexitHubPage + BREXIT_BUSINESS_PAGE_CONTENT_ID = "91cd6143-69d5-4f27-99ff-a52fb0d51c78".freeze + BREXIT_CITIZEN_PAGE_CONTENT_ID = "6555e0bf-c270-4cf9-a0c5-d20b95fab7f1".freeze + BREXIT_HUB_PAGE_CONTENT_IDS = [BREXIT_BUSINESS_PAGE_CONTENT_ID, BREXIT_CITIZEN_PAGE_CONTENT_ID].freeze + BREXIT_BUSINESS_PAGE_PATH = "/guidance/brexit-guidance-for-businesses".freeze + BREXIT_CITIZEN_PAGE_PATH = "/guidance/brexit-guidance-for-individuals-and-families".freeze + + def brexit_links + { + ContentItem::BrexitHubPage::BREXIT_BUSINESS_PAGE_CONTENT_ID => { + text: I18n.t("brexit.citizen_link"), + path: BREXIT_CITIZEN_PAGE_PATH, + }, + ContentItem::BrexitHubPage::BREXIT_CITIZEN_PAGE_CONTENT_ID => { + text: I18n.t("brexit.business_link"), + path: BREXIT_BUSINESS_PAGE_PATH, + }, + } + end + + def brexit_link + brexit_links[content_item.dig("content_id")] + end + end +end diff --git a/app/presenters/content_item_presenter.rb b/app/presenters/content_item_presenter.rb index 8919f445f..f160748d0 100644 --- a/app/presenters/content_item_presenter.rb +++ b/app/presenters/content_item_presenter.rb @@ -1,5 +1,6 @@ class ContentItemPresenter include ContentItem::Withdrawable + include ContentItem::BrexitHubPage attr_reader :content_item, :requested_path, diff --git a/app/views/content_items/detailed_guide.html.erb b/app/views/content_items/detailed_guide.html.erb index 4520e58b9..25484c57d 100644 --- a/app/views/content_items/detailed_guide.html.erb +++ b/app/views/content_items/detailed_guide.html.erb @@ -6,15 +6,24 @@
- <%= render 'govuk_publishing_components/components/title', @content_item.title_and_context %> + <% title_and_context = @content_item.brexit_link ? { title: @content_item.title } : @content_item.title_and_context %> + <%= render 'govuk_publishing_components/components/title', title_and_context %>
<%= render 'shared/translations' %>
- <%= render 'govuk_publishing_components/components/lead_paragraph', text: @content_item.description %> + <% if @content_item.brexit_link %> +
+

+ <%= I18n.t("brexit.heading_prefix") %> <%= link_to @content_item.brexit_link[:text], @content_item.brexit_link[:path] %>. +

+
+ <% else %> + <%= render 'govuk_publishing_components/components/lead_paragraph', text: @content_item.description %> + <% end %>
-<%= render 'shared/publisher_metadata_with_logo' %> +<%= render 'shared/publisher_metadata_with_logo' unless @content_item.brexit_link %> <%= render 'shared/history_notice', content_item: @content_item %> <%= render 'govuk_publishing_components/components/notice', @content_item.withdrawal_notice_component %> @@ -26,7 +35,7 @@ <%= render "govuk_publishing_components/components/print_link", { margin_top: 0, margin_bottom: 6, - } %> + } unless @content_item.brexit_link %> <%= render 'govuk_publishing_components/components/govspeak', {} do %> <%= raw(@content_item.govspeak_body[:content]) %> @@ -37,13 +46,13 @@ published: @content_item.published, last_updated: @content_item.updated, history: @content_item.history - } %> + } unless @content_item.brexit_link %> <% end %> <%= render "govuk_publishing_components/components/print_link", { margin_top: 0, margin_bottom: 6, - } %> + } unless @content_item.brexit_link %> <%= render 'shared/sidebar_navigation' %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 312c8dcd3..661ad7551 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -42,6 +42,8 @@ <% unless @do_not_show_breadcrumbs %> <% if @content_item.try(:back_link) %> <%= render 'govuk_publishing_components/components/back_link', href: @content_item.back_link %> + <% elsif @content_item.brexit_link %> + <%= render 'govuk_publishing_components/components/breadcrumbs', breadcrumbs: [ { url: "/", title: "Home" } , { url: "/transition", title: "Brexit" } ] %> <% else %> <%= render 'govuk_publishing_components/components/contextual_breadcrumbs', content_item: @content_item.content_item.parsed_content %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index ed8aae574..a885e7f70 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -288,6 +288,10 @@ en: written_statement: one: Written statement to Parliament other: Written statements to Parliament + brexit: + heading_prefix: There’s different + business_link: Brexit guidance for businesses + citizen_link: Brexit guidance for individuals and families corporate_information_page: about_our_services_html: Find out %{link}. corporate_information: Corporate information diff --git a/test/integration/detailed_guide_test.rb b/test/integration/detailed_guide_test.rb index 370d3365f..166f1bef1 100644 --- a/test/integration/detailed_guide_test.rb +++ b/test/integration/detailed_guide_test.rb @@ -90,4 +90,26 @@ class DetailedGuideTest < ActionDispatch::IntegrationTest assert_equal faq_schema["name"], @content_item["title"] assert_not_equal faq_schema["mainEntity"], [] end + + test "renders brexit child taxon pages in special ways" do + setup_and_visit_brexit_child_taxon("business") + + # hides the print links + assert_not page.has_css?(".gem-c-print-link") + assert_not page.has_content?("Print this page") + + # hides published by metadata + assert_not page.has_css?(".gem-c-metadata") + + # renders description field as a custom link + assert_not page.has_text?(@content_item["description"]) + link_text = "Brexit guidance for individuals and families" + assert page.has_link?(link_text, href: ContentItem::BrexitHubPage::BREXIT_CITIZEN_PAGE_PATH) + + setup_and_visit_brexit_child_taxon("citizen") + + assert_not page.has_text?(@content_item["description"]) + link_text = "Brexit guidance for businesses" + assert page.has_link?(link_text, href: ContentItem::BrexitHubPage::BREXIT_BUSINESS_PAGE_PATH) + end end diff --git a/test/test_helper.rb b/test/test_helper.rb index ffac52fc5..1b0f5f6ef 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -176,6 +176,22 @@ def setup_and_visit_content_item_with_taxons(name, taxons) end end + def setup_and_visit_brexit_child_taxon(type = nil) + @content_item = get_content_example("detailed_guide").tap do |item| + item["content_id"] = type == "business" ? brexit_business_id : brexit_citizen_id + stub_content_store_has_item(item["base_path"], item.to_json) + visit_with_cachebust((item["base_path"]).to_s) + end + end + + def brexit_citizen_id + ContentItem::BrexitHubPage::BREXIT_CITIZEN_PAGE_CONTENT_ID + end + + def brexit_business_id + ContentItem::BrexitHubPage::BREXIT_BUSINESS_PAGE_CONTENT_ID + end + def setup_and_visit_random_content_item(document_type: nil) content_item = GovukSchemas::RandomExample.for_schema(frontend_schema: schema_type) do |payload| payload.merge!("document_type" => document_type) unless document_type.nil?