Skip to content

Commit

Permalink
Merge pull request #3106 from alphagov/fix-office-link
Browse files Browse the repository at this point in the history
Fix link to worldwide office for translated worldwide organisations
  • Loading branch information
brucebolt authored Feb 21, 2024
2 parents 9b2aaf4 + 043878e commit 0f29ccc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/presenters/worldwide_organisation_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def main_office
WorldwideOffice.new(
contact: WorldwideOrganisation::LinkedContactPresenter.new(office_contact_item),
has_access_and_opening_times?: office_item["access_and_opening_times"].present?,
public_url: "#{content_item['base_path']}/#{office_item['slug']}",
public_url: "#{content_item['base_path'].gsub(/\..*?$/, '')}/#{office_item['slug']}",
)
end

Expand Down
15 changes: 15 additions & 0 deletions test/presenters/worldwide_organisation_presenter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,21 @@ def schema_name
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")
Expand Down

0 comments on commit 0f29ccc

Please sign in to comment.