From 538bcdabd5a0913730ae9fcfb5ba3216ce81cb79 Mon Sep 17 00:00:00 2001 From: Bruce Bolt Date: Tue, 2 Jan 2024 13:27:56 +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 | 4 ++++ app/presenters/worldwide_office_presenter.rb | 4 ++++ app/presenters/worldwide_organisation/branding.rb | 2 +- app/presenters/worldwide_organisation_presenter.rb | 4 ++++ .../integration/worldwide_corporate_information_page_test.rb | 3 ++- test/integration/worldwide_office_test.rb | 5 +++-- test/integration/worldwide_organisation_test.rb | 2 +- 7 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/presenters/worldwide_corporate_information_page_presenter.rb b/app/presenters/worldwide_corporate_information_page_presenter.rb index 74b68cf3ec..7f4ca7dde4 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 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