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

Fix link to worldwide office for translated worldwide organisations #3106

Merged
merged 1 commit into from
Feb 21, 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
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
Loading