From f2ed09f59781d4cf1f79757767b92579ac2a7030 Mon Sep 17 00:00:00 2001 From: Bruce Bolt Date: Wed, 21 Feb 2024 10:35:43 +0000 Subject: [PATCH] Remove Worldwide Office rendering code In https://github.com/alphagov/government-frontend/pull/3095, we introduced code that supports Worldwide Offices being included in the Worldwide Organisation content item, whilst also supporting standalone Worldwide Office content items. We have now removed all the Worldwide Office content items and the code that renders them, so can remove the rendering code from this application. --- app/presenters/worldwide_office_presenter.rb | 38 ------ .../content_items/worldwide_office.html.erb | 35 ------ config/govuk_examples.yml | 5 - test/integration/worldwide_office_test.rb | 111 ------------------ .../worldwide_office_presenter_test.rb | 58 --------- .../linked_contact_presenter_test.rb | 2 +- 6 files changed, 1 insertion(+), 248 deletions(-) delete mode 100644 app/presenters/worldwide_office_presenter.rb delete mode 100644 app/views/content_items/worldwide_office.html.erb delete mode 100644 test/integration/worldwide_office_test.rb delete mode 100644 test/presenters/worldwide_office_presenter_test.rb diff --git a/app/presenters/worldwide_office_presenter.rb b/app/presenters/worldwide_office_presenter.rb deleted file mode 100644 index d65d7fc63..000000000 --- a/app/presenters/worldwide_office_presenter.rb +++ /dev/null @@ -1,38 +0,0 @@ -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 - - def contact - contact = content_item.dig("links", "contact")&.first - - WorldwideOrganisation::LinkedContactPresenter.new(contact) - end - - def show_default_breadcrumbs? - false - end - - def worldwide_organisation - return unless content_item.dig("links", "worldwide_organisation") - - WorldwideOrganisationPresenter.new(content_item.dig("links", "worldwide_organisation").first, requested_path, view_context) - end - - def sponsoring_organisations - worldwide_organisation&.sponsoring_organisations - end - -private - - def show_contents_list? - true - end -end diff --git a/app/views/content_items/worldwide_office.html.erb b/app/views/content_items/worldwide_office.html.erb deleted file mode 100644 index eac88d649..000000000 --- a/app/views/content_items/worldwide_office.html.erb +++ /dev/null @@ -1,35 +0,0 @@ -<%= render partial: "content_items/worldwide_organisation/header", locals: { - worldwide_organisation: @content_item.worldwide_organisation, -} %> - -
-
- <%= render "govuk_publishing_components/components/contents_list", - contents: @content_item.contents, - underline_links: true - %> -
- -
-
- <%= render "govuk_publishing_components/components/heading", { - text: sanitize("About #{@content_item.contact.title}"), - heading_level: 2, - font_size: "xl", - margin_bottom: 4, - } %> - -
-
- <%= render partial: "content_items/worldwide_organisation/contact", locals: { - contact: @content_item.contact, - hide_title: true, - } %> -
- - <%= render "govuk_publishing_components/components/govspeak", {} do - raw(@content_item.body) - end %> -
-
-
diff --git a/config/govuk_examples.yml b/config/govuk_examples.yml index f19693a31..c48346d73 100644 --- a/config/govuk_examples.yml +++ b/config/govuk_examples.yml @@ -195,11 +195,6 @@ working_group_7: '/government/groups/veterans-welfare-service' working_group_8: '/government/groups/uk-national-screening-committee-uk-nsc' working_group_9: '/government/groups/uk-council-for-child-internet-safety-ukccis' -worldwide_office: '/world/organisations/british-consulate-general-barcelona/office/british-consulate-general-barcelona' -worldwide_office_without_access_details: '/world/organisations/british-consulate-general-alexandria/office/consulate-general-alexandria' -worldwide_office_with_many_locations: '/world/organisations/british-embassy-paris/office/british-embassy' -worldwide_office_with_non_default_logo: '/world/organisations/department-for-business-and-trade-ecuador/office/uk-trade-investment-ecuador' - worldwide_organisation: '/world/organisations/british-embassy-madrid' worldwide_organisation_translation: '/world/organisations/british-embassy-madrid.es' worldwide_organisation_with_secondary_corporate_info_pages: '/world/organisations/british-deputy-high-commission-hyderabad' diff --git a/test/integration/worldwide_office_test.rb b/test/integration/worldwide_office_test.rb deleted file mode 100644 index c9670e191..000000000 --- a/test/integration/worldwide_office_test.rb +++ /dev/null @@ -1,111 +0,0 @@ -require "test_helper" - -class WorldwideOfficeTest < ActionDispatch::IntegrationTest - test "includes the title of the organisation" do - setup_and_visit_content_item("worldwide_office") - - assert page.has_title?("British Embassy Manila") - end - - test "includes the title of the office contact" do - setup_and_visit_content_item("worldwide_office") - - assert page.has_selector?("h2", text: "Consular section") - end - - test "omits breadcrumbs" do - setup_and_visit_content_item("worldwide_office") - - assert page.has_no_selector?(".govuk-breadcrumbs") - end - - test "includes access details and contents" do - setup_and_visit_content_item("worldwide_office") - - assert page.has_content? "Contents" - assert_has_contents_list([ - { text: "Disabled access", id: "disabled-access" }, - { text: "Public Holidays for 2023", id: "public-holidays-for-2023" }, - ]) - - assert page.has_content? "The British Embassy Manila is keen to ensure that our building and services are fully accessible to disabled members of the public." - end - - test "omits access details and contents when they are not included in the content item" do - content_item = get_content_example("worldwide_office") - content_item["details"]["access_and_opening_times"] = nil - - stub_content_store_has_item(content_item["base_path"], content_item.to_json) - visit_with_cachebust(content_item["base_path"]) - - assert page.has_selector?("h2", text: "Consular section") - assert_not page.has_content? "Contents" - end - - test "includes the address" do - setup_and_visit_content_item("worldwide_office") - - within find("address", match: :first) do - assert page.has_content? "British Embassy Manila" - assert page.has_content? "120 Upper McKinley Road, McKinley Hill" - assert page.has_content? "Taguig City" - assert page.has_content? "Manila" - assert page.has_content? "1634" - assert page.has_content? "Philippines" - end - end - - test "includes the contact details" do - setup_and_visit_content_item("worldwide_office") - - assert page.has_content? "Email" - assert page.has_link? "ukinthephilippines@fco.gov.uk" - - assert page.has_content? "Contact form" - assert page.has_link? "http://www.gov.uk/cont...", href: "http://www.gov.uk/contact-consulate-manila" - - assert page.has_content? "Telephone" - assert page.has_content? "+63 (02) 8 858 2200 / +44 20 7136 6857 (line open 24/7)" - end - - test "includes the contact comments" do - setup_and_visit_content_item("worldwide_office") - - assert page.has_content? "24/7 consular support is available by telephone for all routine enquiries and emergencies." - end - - 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_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 - setup_and_visit_content_item("worldwide_office") - - within find(".worldwide-organisation-header__metadata", match: :first) do - assert page.has_content? "Location:" - assert page.has_link? "Philippines", href: "/world/philippines/news" - assert page.has_link? "Palau", href: "/world/palau/news" - - assert page.has_content? "Part of:" - assert page.has_link? "Foreign, Commonwealth & Development Office", href: "/government/organisations/foreign-commonwealth-development-office" - end - end - - test "omits the world locations and sponsoring organisations when they are absent" do - content_item = get_content_example("worldwide_office") - content_item["links"]["worldwide_organisation"][0]["links"]["sponsoring_organisations"] = nil - content_item["links"]["worldwide_organisation"][0]["links"]["world_locations"] = nil - - stub_content_store_has_item(content_item["base_path"], content_item.to_json) - visit_with_cachebust(content_item["base_path"]) - - within find(".worldwide-organisation-header__metadata", match: :first) do - assert_not page.has_content? "Location:" - assert_not page.has_content? "Part of:" - end - end -end diff --git a/test/presenters/worldwide_office_presenter_test.rb b/test/presenters/worldwide_office_presenter_test.rb deleted file mode 100644 index cdd0bdddd..000000000 --- a/test/presenters/worldwide_office_presenter_test.rb +++ /dev/null @@ -1,58 +0,0 @@ -require "presenter_test_helper" - -class WorldwideOfficePresenterTest < PresenterTestCase - def schema_name - "worldwide_office" - end - - test "#title returns the title of the schema item" do - assert_equal schema_item["title"], presented_item.title - end - - test "#body returns the access and opening times of the schema item" do - assert_equal schema_item["details"]["access_and_opening_times"], presented_item.body - end - - test "#contact returns the contact as an instance of #{WorldwideOrganisation::LinkedContactPresenter}" do - assert presented_item.contact.is_a?(WorldwideOrganisation::LinkedContactPresenter) - end - - test "#sponsoring_organisation_logo returns the logo details of the item" do - with_non_default_crest = schema_item - sponsoring_organisation = first_sponsoring_organisation(with_non_default_crest) - sponsoring_organisation["details"]["logo"]["crest"] = "dbt" - - 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" } - assert_equal expected, presented.organisation_logo - end - - test "#sponsoring_organisation_logo returns default values when the crest and brand of the first sponsoring organisation are blank" do - with_empty_logo = schema_item - sponsoring_organisation = first_sponsoring_organisation(with_empty_logo) - sponsoring_organisation["details"]["logo"]["crest"] = nil - sponsoring_organisation["details"]["brand"] = nil - - 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" } - assert_equal expected, presented.organisation_logo - end - - test "#sponsoring_organisation_logo returns default values when the sponsoring organisations are nil" do - without_sponsoring_organisations = schema_item - without_sponsoring_organisations["links"]["worldwide_organisation"][0]["links"].delete("sponsoring_organisations") - - 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" } - assert_equal expected, presented.organisation_logo - end - -private - - def first_sponsoring_organisation(item) - item["links"]["worldwide_organisation"][0]["links"]["sponsoring_organisations"][0] - end -end diff --git a/test/presenters/worldwide_organisation/linked_contact_presenter_test.rb b/test/presenters/worldwide_organisation/linked_contact_presenter_test.rb index 34075cf5b..e7bffee80 100644 --- a/test/presenters/worldwide_organisation/linked_contact_presenter_test.rb +++ b/test/presenters/worldwide_organisation/linked_contact_presenter_test.rb @@ -2,7 +2,7 @@ class WorldwideOrganisation::LinkedContactPresenterTest < ActiveSupport::TestCase setup do - content_item = govuk_content_schema_example("worldwide_office", "worldwide_office") + content_item = govuk_content_schema_example("worldwide_organisation", "worldwide_organisation") @contact_content_item = content_item.dig("links", "contact").first end