Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for multi-part Worldwide Organisation content #3118

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/controllers/content_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ def content_item_template
return "guide_single" if @content_item.render_guide_as_single_page?
return "manual_updates" if @content_item.manual_updates?
return "hmrc_manual_updates" if @content_item.hmrc_manual_updates?
return "worldwide_organisation_office" if @content_item.worldwide_organisation_office?

@content_item.schema_name
end
Expand Down
4 changes: 0 additions & 4 deletions app/presenters/content_item_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ def hmrc_manual_updates?
view_context.request.path =~ /^\/hmrc-internal-manuals\/.*\/updates$/ && content_item["schema_name"] == "hmrc_manual"
end

def worldwide_organisation_office?
view_context.request.path =~ /^\/world\/.*\/office\/.*$/ && content_item["schema_name"] == "worldwide_organisation"
end

def show_default_breadcrumbs?
true
end
Expand Down
46 changes: 0 additions & 46 deletions app/presenters/worldwide_organisation_office_presenter.rb

This file was deleted.

24 changes: 15 additions & 9 deletions app/presenters/worldwide_organisation_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ def people_in_non_primary_roles
end

def main_office
return unless (office_item = content_item.dig("details", "main_office_parts")&.first)
return unless (office_item = content_item.dig("links", "main_office")&.first)

office_contact_item = linked_contact(office_item["contact_content_id"])
office_contact_item = contact_for_office(office_item["content_id"])
return unless office_contact_item

office(office_item, office_contact_item)
end

def home_page_offices
return [] unless content_item.dig("details", "home_page_office_parts")
return [] unless content_item.dig("links", "home_page_offices")

content_item.dig("details", "home_page_office_parts").map { |office|
contact = linked_contact(office["contact_content_id"])
content_item.dig("links", "home_page_offices").map { |office|
contact = contact_for_office(office["content_id"])
next unless contact

office(office, contact)
Expand Down Expand Up @@ -130,14 +130,20 @@ def sponsoring_organisations
def office(office, contact)
WorldwideOffice.new(
contact: WorldwideOrganisation::LinkedContactPresenter.new(contact),
has_access_and_opening_times?: office["access_and_opening_times"].present?,
public_url: "#{content_item['base_path'].gsub(/\..*?$/, '')}/#{office['slug']}",
has_access_and_opening_times?: office.dig("details", "access_and_opening_times").present?,
public_url: office["base_path"],
)
end

def linked_contact(contact_content_id)
def contact_for_office(office_content_id)
contact_mapping = content_item.dig("details", "office_contact_associations").select { |office_contact_association|
office_contact_association["office_content_id"] == office_content_id
}.first

return unless contact_mapping

content_item.dig("links", "contacts").select { |contact|
contact["content_id"] == contact_content_id
contact["content_id"] == contact_mapping["contact_content_id"]
}.first
end

Expand Down
5 changes: 0 additions & 5 deletions app/services/presenter_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def presenter_name
return service_sign_in_presenter_name if service_sign_in_format?
return "ManualUpdatesPresenter" if manual_updates?
return "HmrcManualUpdatesPresenter" if hmrc_manual_updates?
return "WorldwideOrganisationOfficePresenter" if worldwide_organisation_office?

"#{content_item['schema_name'].classify}Presenter"
end
Expand All @@ -50,10 +49,6 @@ def hmrc_manual_updates?
view_context.request.path =~ /^\/hmrc-internal-manuals\/.*\/updates$/ && content_item["schema_name"] == "hmrc_manual"
end

def worldwide_organisation_office?
view_context.request.path =~ /^\/world\/.*\/office\/.*$/ && content_item["schema_name"] == "worldwide_organisation"
end

def service_sign_in_format?
content_item["schema_name"] == "service_sign_in"
end
Expand Down
35 changes: 0 additions & 35 deletions app/views/content_items/worldwide_organisation_office.html.erb

This file was deleted.

8 changes: 4 additions & 4 deletions test/integration/worldwide_organisation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ class WorldwideOrganisationTest < ActionDispatch::IntegrationTest

within("#contact-us") do
assert page.has_text?("Contact us")
assert page.has_content?("Torre Emperador Castellana")
assert page.has_link?(I18n.t("contact.access_and_opening_times"), href: "/world/uk-embassy-in-country/office/british-embassy")
assert page.has_content?("British Embassy Madrid")
assert page.has_link?(I18n.t("contact.access_and_opening_times"), href: "/world/organisations/british-embassy-madrid/office/british-embassy")
end
end

Expand Down Expand Up @@ -142,7 +142,7 @@ class WorldwideOrganisationTest < ActionDispatch::IntegrationTest

within("#contact-us") do
assert page.has_content?("Department for Business and Trade Dusseldorf")
assert page.has_link?(I18n.t("contact.access_and_opening_times"), href: "/world/uk-embassy-in-country/office/uk-trade-investment-duesseldorf")
assert page.has_link?(I18n.t("contact.access_and_opening_times"), href: "/world/organisations/department-for-business-and-trade-germany/office/uk-trade-investment-duesseldorf")
end
end

Expand Down Expand Up @@ -174,7 +174,7 @@ class WorldwideOrganisationTest < ActionDispatch::IntegrationTest
setup_and_visit_content_item(
"worldwide_organisation",
{
"details" => { "main_office_parts" => nil },
"links" => { "main_office" => nil },
},
)
assert_not page.has_text?("Contact us")
Expand Down
70 changes: 0 additions & 70 deletions test/presenters/worldwide_organisation_office_presenter_test.rb

This file was deleted.

19 changes: 2 additions & 17 deletions test/presenters/worldwide_organisation_presenter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,31 +157,16 @@ def schema_name

test "#main_office returns nil when there is no main office" do
without_main_office = schema_item
without_main_office["details"].delete("main_office_parts")
without_main_office["links"].delete("main_office")

presented = create_presenter(WorldwideOrganisationPresenter, content_item: without_main_office)

assert_nil presented.main_office
end

test "#main_office returns the correct link when the worldwide organisation is not a translation" do
presented = create_presenter(WorldwideOrganisationPresenter, content_item: schema_item)

assert_equal "/world/uk-embassy-in-country/office/british-embassy", presented.main_office.public_url
end

test "#main_office returns the correct link when the worldwide organisation is a translation" do
content_item = schema_item
content_item["base_path"] = "#{content_item['base_path']}.fr"

presented = create_presenter(WorldwideOrganisationPresenter, content_item:)

assert_equal "/world/uk-embassy-in-country/office/british-embassy", presented.main_office.public_url
end

test "#home_page_offices returns an empty array when there are no home page offices" do
without_home_page_offices = schema_item
without_home_page_offices["details"].delete("home_page_office_parts")
without_home_page_offices["links"].delete("home_page_offices")

presented = create_presenter(WorldwideOrganisationPresenter, content_item: without_home_page_offices)

Expand Down
Loading