Skip to content

Commit

Permalink
Merge pull request #3029 from alphagov/use-ww-org-formatted-name
Browse files Browse the repository at this point in the history
Use formatted name for worldwide organisations
  • Loading branch information
brucebolt authored Jan 3, 2024
2 parents 543f082 + bae6511 commit 6a31f32
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 15 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 All @@ -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?
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions test/integration/worldwide_office_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
Original file line number Diff line number Diff line change
Expand Up @@ -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<br/>Manila", url: "/world/organisations/british-embassy-manila", crest: "dbt", brand: "foreign-commonwealth-development-office" }
assert_equal expected, presented.organisation_logo
end

Expand All @@ -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<br/>Manila", url: "/world/organisations/british-embassy-manila", crest: "single-identity", brand: "single-identity" }
assert_equal expected, presented.organisation_logo
end

Expand All @@ -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<br/>Manila", url: "/world/organisations/british-embassy-manila", crest: "single-identity", brand: "single-identity" }
assert_equal expected, presented.organisation_logo
end

Expand Down
6 changes: 3 additions & 3 deletions test/presenters/worldwide_office_presenter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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<br/>Manila", url: "/world/organisations/british-embassy-manila", crest: "dbt", brand: "foreign-commonwealth-development-office" }
assert_equal expected, presented.organisation_logo
end

Expand All @@ -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<br/>Manila", url: "/world/organisations/british-embassy-manila", crest: "single-identity", brand: "single-identity" }
assert_equal expected, presented.organisation_logo
end

Expand All @@ -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<br/>Manila", url: "/world/organisations/british-embassy-manila", crest: "single-identity", brand: "single-identity" }
assert_equal expected, presented.organisation_logo
end

Expand Down

0 comments on commit 6a31f32

Please sign in to comment.