From 75d05d73ecdce8c2ebe5d542b08941a15fd6d66c Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 8 Aug 2018 16:24:59 +0100 Subject: [PATCH 1/2] Revert "Change the special case to not have the "the"" I have no idea what this did, but it didn't affect the related links as I'd hoped, as it turns out that the code for them is in the govuk_publishing_components gem. This reverts commit 84cc5f842332600b8a0cbf3da2c15f7ff189b555. --- app/services/world_location_base_path.rb | 2 +- test/services/world_location_base_path_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/world_location_base_path.rb b/app/services/world_location_base_path.rb index 8fd2ded7a..756028816 100644 --- a/app/services/world_location_base_path.rb +++ b/app/services/world_location_base_path.rb @@ -22,7 +22,7 @@ class WorldLocationBasePath EXCEPTIONAL_CASES = { "Democratic Republic of Congo" => "democratic-republic-of-congo", - "South Georgia and the South Sandwich Islands" => "south-georgia-and-south-sandwich-islands", + "South Georgia and the South Sandwich Islands" => "south-georgia-and-the-south-sandwich-islands", "St Pierre & Miquelon" => "st-pierre-miquelon" }.freeze diff --git a/test/services/world_location_base_path_test.rb b/test/services/world_location_base_path_test.rb index 69468683f..c987a6e33 100644 --- a/test/services/world_location_base_path_test.rb +++ b/test/services/world_location_base_path_test.rb @@ -22,7 +22,7 @@ class WorldLocationBasePathWithoutBasePath < ActiveSupport::TestCase class WorldLocationBasePathForExceptionalCase < ActiveSupport::TestCase { "Democratic Republic of Congo" => "democratic-republic-of-congo", - "South Georgia and the South Sandwich Islands" => "south-georgia-and-south-sandwich-islands", + "South Georgia and the South Sandwich Islands" => "south-georgia-and-the-south-sandwich-islands", "St Pierre & Miquelon" => "st-pierre-miquelon" }.each do |title, expected_slug| test "returns /world/#{expected_slug}/news" do From 30c93d226f243f380d92e427cc7fe2d71c991499 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 8 Aug 2018 16:40:11 +0100 Subject: [PATCH 2/2] Clean up the WorldLocationBasePath class As far as I can work out, this is never used. The only document type that uses the metadata, which is I think where this is possibly used is travel advice. I checked if any travel advice content is tagged to world locations, and it isn't. This is very confusing, as the exceptional cases aren't exceptional. Looking at the code, the behaviour looks to be the same with or without them. I've also removed the comment, as the situation with the migration of "world locations to a taxonomy based model" is pretty uncertian, as the Topic Taxonomy doesn't have anything to do with country classification (it's about subject, not geography), and this "temporary solution" both as far as I can work out, doesn't do anything, and has been here for over a year. --- app/services/world_location_base_path.rb | 29 +----------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/app/services/world_location_base_path.rb b/app/services/world_location_base_path.rb index 756028816..0276bd47e 100644 --- a/app/services/world_location_base_path.rb +++ b/app/services/world_location_base_path.rb @@ -1,38 +1,11 @@ -#This is intended as a temporary solution while dependencies on other apps are -#resolved. We are migrating world locations to a taxonomy based model but the -#following problems have arisen that this approach temporarily solves: -# -# * we require world locations to be associated with content in Whitehall -# for email subscriptions to work so we can't just get rid of them -# * we also need them as not all content will be part of the taxonomy -# (e.g. news about the country) -# * the taxon will take the base path (/world/) and so the -# WorldLocation can't occupy that -# * we need to redirect old /government/world/ urls to the new -# taxon but if we leave WorldLocation with that path it will a) overwrite -# the redirect route every time it is updated and b) we'll be knowingly -# linking to a redirect -# -#A slightly better solution will be for Whitehall to retrieve the taxon path from -#publishing API and send that with the world location link as an additional field -#in the links. We'll need the taxonomy to exist in order to implement this. This -#will still require frontend code to know about the links but will be similar -#to prior art we have for some links to be affected by elements with `detail`. - class WorldLocationBasePath - EXCEPTIONAL_CASES = { - "Democratic Republic of Congo" => "democratic-republic-of-congo", - "South Georgia and the South Sandwich Islands" => "south-georgia-and-the-south-sandwich-islands", - "St Pierre & Miquelon" => "st-pierre-miquelon" - }.freeze - class << self def for(world_location_link) base_path = world_location_link["base_path"] title = world_location_link["title"] return base_path if base_path.present? - slug = EXCEPTIONAL_CASES[title] || title.parameterize + slug = title.parameterize "/world/#{slug}/news" end