Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add special case for 'UK mission in the European Union'
Browse files Browse the repository at this point in the history
The slug for the world location 'UK mission in the European Union'
doesn't match exactly the title of the world location. Instead the slug
shortens 'European Union' to 'EU'.

This means that links to this world location are currently broken (for
example
https://www.gov.uk/government/speeches/triggering-the-jcpoa-dispute-resolution-mechanism-foreign-secretarys-commons-statement
(see section at the bottom of the page).

This is similar to the special cases that we used to have in
government-frontend before they were removed and moved into
govuk_publishing_components:
alphagov/government-frontend#1035
thomasleese committed Feb 3, 2020

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent fedb60f commit 0ee1b09
Showing 3 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,10 @@
useful summary for people upgrading their application, not a replication
of the commit log.

## Unreleased

* Fix a world location link for 'UK mission in the European Union' ([#1274](https://github.com/alphagov/govuk_publishing_components/pull/1274))

## 21.21.3

* Increase margin between related step by step links and adjust font weight ([#1269](https://github.com/alphagov/govuk_publishing_components/pull/1269))
Original file line number Diff line number Diff line change
@@ -12,6 +12,9 @@ class RelatedNavigationHelper
world_locations
statistical_data_sets
).freeze
WORLD_LOCATION_SPECIAL_CASES = {
'UK Mission to the European Union' => 'uk-mission-to-the-eu',
}.freeze

def initialize(options = {})
@content_item = options.fetch(:content_item) { raise ArgumentError, 'missing argument: content_item' }
@@ -146,7 +149,10 @@ def related_items

def related_world_locations
content_item_links_for('world_locations')
.map { |link| link.merge(path: "/world/#{link[:text].parameterize}/news") }
.map do |link|
slug = WORLD_LOCATION_SPECIAL_CASES[link[:text]] || link[:text].parameterize
link.merge(path: "/world/#{slug}/news")
end
end

def related_statistical_data_sets
9 changes: 9 additions & 0 deletions spec/components/related_navigation_spec.rb
Original file line number Diff line number Diff line change
@@ -78,6 +78,15 @@ def construct_links(type, base_path, title, document_type = nil, locale = nil)
assert_select ".gem-c-related-navigation__section-link[href=\"/world/usa/news\"]", text: 'USA'
end

it "renders world locations section when passed special case world location items" do
content_item = {}
content_item["links"] = construct_links("world_locations", nil, "UK mission to the European Union")
render_component(content_item: content_item)

assert_select ".gem-c-related-navigation__sub-heading", text: 'World locations'
assert_select ".gem-c-related-navigation__section-link[href=\"/world/uk-mission-to-the-eu/news\"]", text: 'UK mission to the European Union'
end

it "renders collection section when passed collection items" do
content_item = {}
content_item["links"] = construct_links(

0 comments on commit 0ee1b09

Please sign in to comment.