From 2534d7674f127d4895f764d5bc6a5cd29b86965a Mon Sep 17 00:00:00 2001 From: Peter Hartshorn Date: Tue, 7 Feb 2023 12:47:43 +0000 Subject: [PATCH 1/2] Add banner presenter method We need to display a banner on three org about pages as a result of the reshuffle, this presenter method will be used by the view to determine whether to display the banner or not. --- app/presenters/corporate_information_page_presenter.rb | 10 ++++++++++ .../corporate_information_page_presenter_test.rb | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/app/presenters/corporate_information_page_presenter.rb b/app/presenters/corporate_information_page_presenter.rb index 252146e14..b789b9466 100644 --- a/app/presenters/corporate_information_page_presenter.rb +++ b/app/presenters/corporate_information_page_presenter.rb @@ -5,6 +5,12 @@ class CorporateInformationPagePresenter < ContentItemPresenter include ContentItem::OrganisationBranding include ContentItem::CorporateInformationGroups + ORG_CHANGING_BANNER_BASE_PATHS = %w[ + /government/organisations/department-for-business-energy-and-industrial-strategy/about + /government/organisations/department-for-international-trade/about + /government/organisations/department-for-business-energy-and-industrial-strategy/about + ].freeze + def page_title page_title = super page_title += " - #{default_organisation['title']}" if default_organisation @@ -22,6 +28,10 @@ def contents_items super + extra_headings end + def show_organisation_changing_banner? + ORG_CHANGING_BANNER_BASE_PATHS.include?(base_path) + end + private def extra_headings diff --git a/test/presenters/corporate_information_page_presenter_test.rb b/test/presenters/corporate_information_page_presenter_test.rb index 33c25766e..b241c5cd8 100644 --- a/test/presenters/corporate_information_page_presenter_test.rb +++ b/test/presenters/corporate_information_page_presenter_test.rb @@ -77,5 +77,15 @@ def schema_name assert presented_item.further_information.include?(information_charter["base_path"]) assert presented_item.further_information.include?(information_charter["title"]) end + + test "returns true for about pages that require a banner" do + presented_item = presented_item(schema_name, "base_path" => "/government/organisations/department-for-business-energy-and-industrial-strategy/about") + assert presented_item.show_organisation_changing_banner? + end + + test "returns false for about pages that don't require a banner" do + presented_item = presented_item(schema_name, "base_path" => "/government/organisations/a-random-org/about") + assert_not presented_item.show_organisation_changing_banner? + end end end From 8e8b10768c360c3c10b2f013086de2455e155040 Mon Sep 17 00:00:00 2001 From: Peter Hartshorn Date: Tue, 7 Feb 2023 12:49:14 +0000 Subject: [PATCH 2/2] Add banner for eligible pages --- .../content_items/corporate_information_page.html.erb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/views/content_items/corporate_information_page.html.erb b/app/views/content_items/corporate_information_page.html.erb index e3e9982cf..bdf91e4b3 100644 --- a/app/views/content_items/corporate_information_page.html.erb +++ b/app/views/content_items/corporate_information_page.html.erb @@ -4,6 +4,15 @@ ) %> <% end %> +<% if @content_item.show_organisation_changing_banner? %> +
+ <%= render "govuk_publishing_components/components/notice", { + title: sanitize('This organisation is changing. Read the latest updates on government departments or visit the 10 Downing Street Twitter feed.'), + margin_bottom: 3, + } %> +
+<% end %> + <% @additional_body = capture do %> <% if @content_item.corporate_information? %> <%= @content_item.corporate_information_heading_tag %>