Skip to content

Commit

Permalink
Use relative URL for worldwide organisation links
Browse files Browse the repository at this point in the history
Links from the Worldwide Organisation pages currently use the `web_url`,
which is absolute, and never includes the draft part of the URL.

This means that a user viewing a draft Worldwide Organisation will be
taken to the live version of the page.

Updating to make the URL relative, meaning users are always taken to the
correct version of the page.

This was never previously an issue, since worldwide organisations have
not previously been editionable.
  • Loading branch information
brucebolt committed May 8, 2024
1 parent 8885d99 commit 548dafd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions app/presenters/worldwide_organisation_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def person_in_primary_role

{
name: person["title"],
href: person["web_url"],
href: person["base_path"],
image_url: person["details"]["image"]["url"],
image_alt: person["details"]["image"]["alt_text"],
description: presented_title_for_roles(current_roles),
Expand All @@ -72,7 +72,7 @@ def people_in_non_primary_roles

{
name: person["title"],
href: person["web_url"],
href: person["base_path"],
description: presented_title_for_roles(current_roles),
}
end
Expand Down Expand Up @@ -110,7 +110,7 @@ def corporate_information_pages
return if ordered_cips.blank?

ordered_cips.map do |cip|
link = cips.find { |cp| cp["content_id"] == cip["content_id"] }["web_url"]
link = cips.find { |cp| cp["content_id"] == cip["content_id"] }["base_path"]
link_to(cip["title"], link, class: "govuk-link").html_safe
end
end
Expand Down
8 changes: 4 additions & 4 deletions test/integration/worldwide_organisation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ class WorldwideOrganisationTest < ActionDispatch::IntegrationTest

test "renders the person in the primary role" do
setup_and_visit_content_item("worldwide_organisation")
assert page.has_link?("Karen Pierce DCMG", href: "https://www.integration.publishing.service.gov.uk/government/people/karen-pierce")
assert page.has_link?("Karen Pierce DCMG", href: "/government/people/karen-pierce")
assert page.has_css?("img[src=\"https://assets.publishing.service.gov.uk/government/uploads/system/uploads/person/image/583/s216_UKMissionGeneva__HMA_Karen_Pierce_-_uploaded.jpg\"]")
end

test "renders people in secondary and office roles" do
setup_and_visit_content_item("worldwide_organisation")
assert page.has_link?("Justin Sosne", href: "https://www.integration.publishing.service.gov.uk/government/people/justin-sosne")
assert page.has_link?("Rachel Galloway", href: "https://www.integration.publishing.service.gov.uk/government/people/rachel-galloway")
assert page.has_link?("Justin Sosne", href: "/government/people/justin-sosne")
assert page.has_link?("Rachel Galloway", href: "/government/people/rachel-galloway")
end

test "doesn't render the people section if there are no appointed people" do
Expand All @@ -52,7 +52,7 @@ class WorldwideOrganisationTest < ActionDispatch::IntegrationTest

test "renders the navigational corporate information pages" do
setup_and_visit_content_item("worldwide_organisation")
assert page.has_link?("Complaints procedure", href: "https://www.integration.publishing.service.gov.uk/world/organisations/british-deputy-high-commission-hyderabad/about/complaints-procedure")
assert page.has_link?("Complaints procedure", href: "/world/organisations/british-deputy-high-commission-hyderabad/about/complaints-procedure")
end

test "renders the secondary corporate information pages" do
Expand Down

0 comments on commit 548dafd

Please sign in to comment.