From b950143826545eef2e3d9f71f09f8ad41335a61a Mon Sep 17 00:00:00 2001 From: Bruce Bolt Date: Tue, 2 Jan 2024 14:25:53 +0000 Subject: [PATCH] Use formatted name for worldwide organisations We are currently presenting the Worldwide Organisation's title in the logo. This means there are no line breaks in the places specified by the user. Updating to use the formatted title, which the publisher would have expected since they entered this in Whitehall. This also applies the change to Worldwide Offices and Worldwide Corporate Information Pages, which include the Worldwide Organisation's logo in the header. --- .../worldwide_corporate_information_page_presenter.rb | 8 ++++---- app/presenters/worldwide_office_presenter.rb | 4 ++++ app/presenters/worldwide_organisation/branding.rb | 2 +- app/presenters/worldwide_organisation_presenter.rb | 4 ++++ .../worldwide_corporate_information_page_test.rb | 3 ++- test/integration/worldwide_office_test.rb | 5 +++-- test/integration/worldwide_organisation_test.rb | 2 +- ...worldwide_corporate_information_page_presenter_test.rb | 6 +++--- test/presenters/worldwide_office_presenter_test.rb | 6 +++--- 9 files changed, 25 insertions(+), 15 deletions(-) diff --git a/app/presenters/worldwide_corporate_information_page_presenter.rb b/app/presenters/worldwide_corporate_information_page_presenter.rb index 74b68cf3ec..d305f5d844 100644 --- a/app/presenters/worldwide_corporate_information_page_presenter.rb +++ b/app/presenters/worldwide_corporate_information_page_presenter.rb @@ -3,6 +3,10 @@ class WorldwideCorporateInformationPagePresenter < ContentItemPresenter include ContentItem::ContentsList include WorldwideOrganisation::Branding + def formatted_title + worldwide_organisation&.formatted_title + end + def show_default_breadcrumbs? false end @@ -17,10 +21,6 @@ def sponsoring_organisations worldwide_organisation&.sponsoring_organisations end - def organisation_logo - super.merge!(name: worldwide_organisation&.title) - end - private def show_contents_list? diff --git a/app/presenters/worldwide_office_presenter.rb b/app/presenters/worldwide_office_presenter.rb index bf26290d85..d65d7fc637 100644 --- a/app/presenters/worldwide_office_presenter.rb +++ b/app/presenters/worldwide_office_presenter.rb @@ -2,6 +2,10 @@ class WorldwideOfficePresenter < ContentItemPresenter include ContentItem::ContentsList include WorldwideOrganisation::Branding + def formatted_title + worldwide_organisation&.formatted_title + end + def body content_item.dig("details", "access_and_opening_times") end diff --git a/app/presenters/worldwide_organisation/branding.rb b/app/presenters/worldwide_organisation/branding.rb index bdfaabf488..72aa32cb43 100644 --- a/app/presenters/worldwide_organisation/branding.rb +++ b/app/presenters/worldwide_organisation/branding.rb @@ -7,7 +7,7 @@ def organisation_logo sponsoring_organisation = sponsoring_organisations&.first { - name: content_item["title"], + name: formatted_title.html_safe, url: link_to_organisation ? worldwide_organisation.base_path : nil, crest: sponsoring_organisation&.dig("details", "logo", "crest") || DEFAULT_ORGANISATION_LOGO, brand: sponsoring_organisation&.dig("details", "brand") || DEFAULT_ORGANISATION_LOGO, diff --git a/app/presenters/worldwide_organisation_presenter.rb b/app/presenters/worldwide_organisation_presenter.rb index 7d116f2f13..b7f98fd07f 100644 --- a/app/presenters/worldwide_organisation_presenter.rb +++ b/app/presenters/worldwide_organisation_presenter.rb @@ -3,6 +3,10 @@ class WorldwideOrganisationPresenter < ContentItemPresenter include WorldwideOrganisation::Branding include ActionView::Helpers::UrlHelper + def formatted_title + content_item.dig("details", "logo", "formatted_title") + end + def sponsoring_organisation_links return if sponsoring_organisations.empty? diff --git a/test/integration/worldwide_corporate_information_page_test.rb b/test/integration/worldwide_corporate_information_page_test.rb index 3e01c505b4..c09e7e2cb9 100644 --- a/test/integration/worldwide_corporate_information_page_test.rb +++ b/test/integration/worldwide_corporate_information_page_test.rb @@ -41,7 +41,8 @@ class WorldwideCorporateInformationPageTest < ActionDispatch::IntegrationTest setup_and_visit_content_item("worldwide_corporate_information_page") assert_has_component_organisation_logo - assert page.has_link? "British Embassy Manila", href: "/world/organisations/british-embassy-manila" + assert_has_component_title("British Embassy\nManila") + assert page.has_link? "British EmbassyManila", href: "/world/organisations/british-embassy-manila" end test "includes the world locations and sponsoring organisations" do diff --git a/test/integration/worldwide_office_test.rb b/test/integration/worldwide_office_test.rb index c1fa89b837..c9670e1917 100644 --- a/test/integration/worldwide_office_test.rb +++ b/test/integration/worldwide_office_test.rb @@ -74,11 +74,12 @@ class WorldwideOfficeTest < ActionDispatch::IntegrationTest assert page.has_content? "24/7 consular support is available by telephone for all routine enquiries and emergencies." end - test "includes the logo and name of the worldwide organisation as a link" do + test "includes the logo and formatted name of the worldwide organisation as a link" do setup_and_visit_content_item("worldwide_office") assert_has_component_organisation_logo - assert page.has_link? "British Embassy Manila", href: "/world/organisations/british-embassy-manila" + assert_has_component_title("British Embassy\nManila") + assert page.has_link? "British EmbassyManila", href: "/world/organisations/british-embassy-manila" end test "includes the world locations and sponsoring organisations" do diff --git a/test/integration/worldwide_organisation_test.rb b/test/integration/worldwide_organisation_test.rb index 9c271f84bb..c4b9563804 100644 --- a/test/integration/worldwide_organisation_test.rb +++ b/test/integration/worldwide_organisation_test.rb @@ -3,7 +3,7 @@ class WorldwideOrganisationTest < ActionDispatch::IntegrationTest test "renders basic worldwide organisation page" do setup_and_visit_content_item("worldwide_organisation") - assert_has_component_title(@content_item["title"]) + assert_has_component_title("British Deputy High Commission\nHyderabad") assert page.has_text?(@content_item["description"]) end diff --git a/test/presenters/worldwide_corporate_information_page_presenter_test.rb b/test/presenters/worldwide_corporate_information_page_presenter_test.rb index 6eb7d7f785..b3e1a2c402 100644 --- a/test/presenters/worldwide_corporate_information_page_presenter_test.rb +++ b/test/presenters/worldwide_corporate_information_page_presenter_test.rb @@ -20,7 +20,7 @@ def schema_name presented = create_presenter(WorldwideCorporateInformationPagePresenter, content_item: with_non_default_crest) - expected = { name: "British Embassy Manila", url: "/world/organisations/british-embassy-manila", crest: "dbt", brand: "foreign-commonwealth-development-office" } + expected = { name: "British Embassy
Manila", url: "/world/organisations/british-embassy-manila", crest: "dbt", brand: "foreign-commonwealth-development-office" } assert_equal expected, presented.organisation_logo end @@ -32,7 +32,7 @@ def schema_name presented = create_presenter(WorldwideCorporateInformationPagePresenter, content_item: with_empty_logo) - expected = { name: "British Embassy Manila", url: "/world/organisations/british-embassy-manila", crest: "single-identity", brand: "single-identity" } + expected = { name: "British Embassy
Manila", url: "/world/organisations/british-embassy-manila", crest: "single-identity", brand: "single-identity" } assert_equal expected, presented.organisation_logo end @@ -42,7 +42,7 @@ def schema_name presented = create_presenter(WorldwideCorporateInformationPagePresenter, content_item: without_sponsoring_organisations) - expected = { name: "British Embassy Manila", url: "/world/organisations/british-embassy-manila", crest: "single-identity", brand: "single-identity" } + expected = { name: "British Embassy
Manila", url: "/world/organisations/british-embassy-manila", crest: "single-identity", brand: "single-identity" } assert_equal expected, presented.organisation_logo end diff --git a/test/presenters/worldwide_office_presenter_test.rb b/test/presenters/worldwide_office_presenter_test.rb index f2c2cc9e6c..cdd0bdddd7 100644 --- a/test/presenters/worldwide_office_presenter_test.rb +++ b/test/presenters/worldwide_office_presenter_test.rb @@ -24,7 +24,7 @@ def schema_name presented = create_presenter(WorldwideOfficePresenter, content_item: with_non_default_crest) - expected = { name: "British Embassy Manila", url: "/world/organisations/british-embassy-manila", crest: "dbt", brand: "foreign-commonwealth-development-office" } + expected = { name: "British Embassy
Manila", url: "/world/organisations/british-embassy-manila", crest: "dbt", brand: "foreign-commonwealth-development-office" } assert_equal expected, presented.organisation_logo end @@ -36,7 +36,7 @@ def schema_name presented = create_presenter(WorldwideOfficePresenter, content_item: with_empty_logo) - expected = { name: "British Embassy Manila", url: "/world/organisations/british-embassy-manila", crest: "single-identity", brand: "single-identity" } + expected = { name: "British Embassy
Manila", url: "/world/organisations/british-embassy-manila", crest: "single-identity", brand: "single-identity" } assert_equal expected, presented.organisation_logo end @@ -46,7 +46,7 @@ def schema_name presented = create_presenter(WorldwideOfficePresenter, content_item: without_sponsoring_organisations) - expected = { name: "British Embassy Manila", url: "/world/organisations/british-embassy-manila", crest: "single-identity", brand: "single-identity" } + expected = { name: "British Embassy
Manila", url: "/world/organisations/british-embassy-manila", crest: "single-identity", brand: "single-identity" } assert_equal expected, presented.organisation_logo end