Skip to content

Commit 125f9cd

Browse files
committed
Remove support for multi-part Worldwide Organisation content
In previous commits, we added support for Worldwide Organisations and their offices to be presented within a single content item. This approach was decided against, since there were issues with translated organisations. Therefore reverting the code that added this support. This reverts commits 043878e, 0c88e11 and 89e7756.
1 parent 85c3efd commit 125f9cd

9 files changed

+21
-191
lines changed

app/controllers/content_items_controller.rb

-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ def content_item_template
177177
return "guide_single" if @content_item.render_guide_as_single_page?
178178
return "manual_updates" if @content_item.manual_updates?
179179
return "hmrc_manual_updates" if @content_item.hmrc_manual_updates?
180-
return "worldwide_organisation_office" if @content_item.worldwide_organisation_office?
181180

182181
@content_item.schema_name
183182
end

app/presenters/content_item_presenter.rb

-4
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@ def hmrc_manual_updates?
110110
view_context.request.path =~ /^\/hmrc-internal-manuals\/.*\/updates$/ && content_item["schema_name"] == "hmrc_manual"
111111
end
112112

113-
def worldwide_organisation_office?
114-
view_context.request.path =~ /^\/world\/.*\/office\/.*$/ && content_item["schema_name"] == "worldwide_organisation"
115-
end
116-
117113
def show_default_breadcrumbs?
118114
true
119115
end

app/presenters/worldwide_organisation_office_presenter.rb

-46
This file was deleted.

app/presenters/worldwide_organisation_presenter.rb

+15-9
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,19 @@ def people_in_non_primary_roles
7979
end
8080

8181
def main_office
82-
return unless (office_item = content_item.dig("details", "main_office_parts")&.first)
82+
return unless (office_item = content_item.dig("links", "main_office")&.first)
8383

84-
office_contact_item = linked_contact(office_item["contact_content_id"])
84+
office_contact_item = contact_for_office(office_item["content_id"])
8585
return unless office_contact_item
8686

8787
office(office_item, office_contact_item)
8888
end
8989

9090
def home_page_offices
91-
return [] unless content_item.dig("details", "home_page_office_parts")
91+
return [] unless content_item.dig("links", "home_page_offices")
9292

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

9797
office(office, contact)
@@ -130,14 +130,20 @@ def sponsoring_organisations
130130
def office(office, contact)
131131
WorldwideOffice.new(
132132
contact: WorldwideOrganisation::LinkedContactPresenter.new(contact),
133-
has_access_and_opening_times?: office["access_and_opening_times"].present?,
134-
public_url: "#{content_item['base_path'].gsub(/\..*?$/, '')}/#{office['slug']}",
133+
has_access_and_opening_times?: office.dig("details", "access_and_opening_times").present?,
134+
public_url: office["base_path"],
135135
)
136136
end
137137

138-
def linked_contact(contact_content_id)
138+
def contact_for_office(office_content_id)
139+
contact_mapping = content_item.dig("details", "office_contact_associations").select { |office_contact_association|
140+
office_contact_association["office_content_id"] == office_content_id
141+
}.first
142+
143+
return unless contact_mapping
144+
139145
content_item.dig("links", "contacts").select { |contact|
140-
contact["content_id"] == contact_content_id
146+
contact["content_id"] == contact_mapping["contact_content_id"]
141147
}.first
142148
end
143149

app/services/presenter_builder.rb

-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def presenter_name
3737
return service_sign_in_presenter_name if service_sign_in_format?
3838
return "ManualUpdatesPresenter" if manual_updates?
3939
return "HmrcManualUpdatesPresenter" if hmrc_manual_updates?
40-
return "WorldwideOrganisationOfficePresenter" if worldwide_organisation_office?
4140

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

53-
def worldwide_organisation_office?
54-
view_context.request.path =~ /^\/world\/.*\/office\/.*$/ && content_item["schema_name"] == "worldwide_organisation"
55-
end
56-
5752
def service_sign_in_format?
5853
content_item["schema_name"] == "service_sign_in"
5954
end

app/views/content_items/worldwide_organisation_office.html.erb

-35
This file was deleted.

test/integration/worldwide_organisation_test.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ class WorldwideOrganisationTest < ActionDispatch::IntegrationTest
107107

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

@@ -142,7 +142,7 @@ class WorldwideOrganisationTest < ActionDispatch::IntegrationTest
142142

143143
within("#contact-us") do
144144
assert page.has_content?("Department for Business and Trade Dusseldorf")
145-
assert page.has_link?(I18n.t("contact.access_and_opening_times"), href: "/world/uk-embassy-in-country/office/uk-trade-investment-duesseldorf")
145+
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")
146146
end
147147
end
148148

@@ -174,7 +174,7 @@ class WorldwideOrganisationTest < ActionDispatch::IntegrationTest
174174
setup_and_visit_content_item(
175175
"worldwide_organisation",
176176
{
177-
"details" => { "main_office_parts" => nil },
177+
"links" => { "main_office" => nil },
178178
},
179179
)
180180
assert_not page.has_text?("Contact us")

test/presenters/worldwide_organisation_office_presenter_test.rb

-70
This file was deleted.

test/presenters/worldwide_organisation_presenter_test.rb

+2-17
Original file line numberDiff line numberDiff line change
@@ -157,31 +157,16 @@ def schema_name
157157

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

162162
presented = create_presenter(WorldwideOrganisationPresenter, content_item: without_main_office)
163163

164164
assert_nil presented.main_office
165165
end
166166

167-
test "#main_office returns the correct link when the worldwide organisation is not a translation" do
168-
presented = create_presenter(WorldwideOrganisationPresenter, content_item: schema_item)
169-
170-
assert_equal "/world/uk-embassy-in-country/office/british-embassy", presented.main_office.public_url
171-
end
172-
173-
test "#main_office returns the correct link when the worldwide organisation is a translation" do
174-
content_item = schema_item
175-
content_item["base_path"] = "#{content_item['base_path']}.fr"
176-
177-
presented = create_presenter(WorldwideOrganisationPresenter, content_item:)
178-
179-
assert_equal "/world/uk-embassy-in-country/office/british-embassy", presented.main_office.public_url
180-
end
181-
182167
test "#home_page_offices returns an empty array when there are no home page offices" do
183168
without_home_page_offices = schema_item
184-
without_home_page_offices["details"].delete("home_page_office_parts")
169+
without_home_page_offices["links"].delete("home_page_offices")
185170

186171
presented = create_presenter(WorldwideOrganisationPresenter, content_item: without_home_page_offices)
187172

0 commit comments

Comments
 (0)