Skip to content

Commit

Permalink
Use formatted name for worldwide organisations
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
brucebolt committed Jan 2, 2024
1 parent e1ed723 commit 1a23c25
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions app/presenters/worldwide_office_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/worldwide_organisation/branding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions app/presenters/worldwide_organisation_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down
4 changes: 4 additions & 0 deletions test/integration/worldwide_corporate_information_page_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class WorldwideCorporateInformationPageTest < ActionDispatch::IntegrationTest
assert page.has_css?("#wrapper.direction-rtl"), "has .direction-rtl class on #wrapper element"
end

test "includes the formatted title of the worldwide organisation" do
assert_has_component_title("British Embassy\nManila")
end

test "includes the body and contents" do
setup_and_visit_content_item("worldwide_corporate_information_page")

Expand Down
4 changes: 4 additions & 0 deletions test/integration/worldwide_office_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class WorldwideOfficeTest < ActionDispatch::IntegrationTest
assert page.has_selector?("h2", text: "Consular section")
end

test "includes the formatted title of the worldwide organisation" do
assert_has_component_title("British Embassy\nManila")
end

test "omits breadcrumbs" do
setup_and_visit_content_item("worldwide_office")

Expand Down
2 changes: 1 addition & 1 deletion test/integration/worldwide_organisation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1a23c25

Please sign in to comment.