Skip to content

Commit

Permalink
Merge pull request #136 from alphagov/url-always-prod
Browse files Browse the repository at this point in the history
Always set document `url` field to production GOV.UK
  • Loading branch information
csutter authored Dec 6, 2023
2 parents a090c33 + 1021a27 commit 6381386
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ gem "govuk_message_queue_consumer"
gem "jsonpath"
gem "loofah"
gem "oj"
gem "plek"

group :test do
gem "grpc_mock"
Expand Down
1 change: 0 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ DEPENDENCIES
jsonpath
loofah
oj
plek
railties (= 7.0.7.2)
rspec-rails
rubocop-govuk
Expand Down
4 changes: 3 additions & 1 deletion app/models/concerns/publishing_api/metadata.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module PublishingApi
module Metadata
WEBSITE_ROOT = "https://www.gov.uk".freeze

# Extracts a hash of structured metadata about this document.
def metadata
{
Expand Down Expand Up @@ -34,7 +36,7 @@ def link_relative?
def url
return link unless link_relative?

Plek.website_root + link
WEBSITE_ROOT + link
end

def public_timestamp
Expand Down
14 changes: 7 additions & 7 deletions spec/integration/document_synchronization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
title: "UK and Japan strengthen cooperation in the area of digital government",
description: "On Monday 31 October 2022, the UK and Japan signed a Memorandum of Cooperation (MoC) to deepen ties on digital government transformation.",
link: "/government/news/uk-and-japan-strengthen-cooperation-in-the-area-of-digital-government",
url: "http://www.dev.gov.uk/government/news/uk-and-japan-strengthen-cooperation-in-the-area-of-digital-government",
url: "https://www.gov.uk/government/news/uk-and-japan-strengthen-cooperation-in-the-area-of-digital-government",
public_timestamp: 1_667_217_614,
document_type: "press_release",
is_historic: 0,
Expand All @@ -50,7 +50,7 @@
title: "Austria travel advice",
description: "FCDO travel advice for Austria. Includes safety and security, insurance, entry requirements and legal differences.",
link: "/foreign-travel-advice/austria",
url: "http://www.dev.gov.uk/foreign-travel-advice/austria",
url: "https://www.gov.uk/foreign-travel-advice/austria",
public_timestamp: 1_697_629_071,
document_type: "travel_advice",
is_historic: 0,
Expand Down Expand Up @@ -104,7 +104,7 @@
title: "Travel advice for fans going to Champions League and Europa League matches this week",
description: "Tottenham, Manchester City and Chelsea are playing matches in Europe this week. If you’re going to the matches, check our travel advice for fans.",
link: "/government/news/travel-advice-for-fans-going-to-champions-league-and-europa-league-matches-this-week",
url: "http://www.dev.gov.uk/government/news/travel-advice-for-fans-going-to-champions-league-and-europa-league-matches-this-week",
url: "https://www.gov.uk/government/news/travel-advice-for-fans-going-to-champions-league-and-europa-league-matches-this-week",
public_timestamp: 1_284_336_000,
document_type: "news_story",
is_historic: 1,
Expand Down Expand Up @@ -134,7 +134,7 @@
title: "6. Body, structure and attachments",
description: "Structure and attachments (including exhaust system and bumpers), and body and interior (including doors and catches, seats and floor) rules and inspection for car and passenger vehicle MOT tests.",
link: "/guidance/mot-inspection-manual-for-private-passenger-and-light-commercial-vehicles/6-body-structure-and-attachments",
url: "http://www.dev.gov.uk/guidance/mot-inspection-manual-for-private-passenger-and-light-commercial-vehicles/6-body-structure-and-attachments",
url: "https://www.gov.uk/guidance/mot-inspection-manual-for-private-passenger-and-light-commercial-vehicles/6-body-structure-and-attachments",
public_timestamp: 1_646_221_134,
document_type: "manual_section",
is_historic: 0,
Expand All @@ -158,7 +158,7 @@
title: "Legal Aid Agency",
description: "We provide civil and criminal legal aid and advice in England and Wales to help people deal with their legal problems. LAA is an executive agency, sponsored by the Ministry of Justice .",
link: "/government/organisations/legal-aid-agency",
url: "http://www.dev.gov.uk/government/organisations/legal-aid-agency",
url: "https://www.gov.uk/government/organisations/legal-aid-agency",
public_timestamp: 1_695_391_634,
document_type: "organisation",
is_historic: 0,
Expand All @@ -183,7 +183,7 @@
title: "Directgov 2010 and beyond: revolution not evolution, a report by Martha Lane Fox",
description: "A report from the Digital Champion Martha Lane Fox with recommendations for the future of Directgov.",
link: "/government/publications/directgov-2010-and-beyond-revolution-not-evolution-a-report-by-martha-lane-fox",
url: "http://www.dev.gov.uk/government/publications/directgov-2010-and-beyond-revolution-not-evolution-a-report-by-martha-lane-fox",
url: "https://www.gov.uk/government/publications/directgov-2010-and-beyond-revolution-not-evolution-a-report-by-martha-lane-fox",
public_timestamp: 1_290_470_400,
document_type: "independent_report",
is_historic: 0,
Expand Down Expand Up @@ -214,7 +214,7 @@
title: "UK help and services in Switzerland",
description: "Services if you're visiting, studying, working or living in Switzerland. Includes information about trading with and doing business in the UK and Switzerland, and your rights after the UK’s exit from the EU.",
link: "/world/switzerland",
url: "http://www.dev.gov.uk/world/switzerland",
url: "https://www.gov.uk/world/switzerland",
public_timestamp: 1_583_165_036,
document_type: "taxon",
is_historic: 0,
Expand Down
10 changes: 2 additions & 8 deletions spec/models/concerns/publishing_api/metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,10 @@
describe "url" do
subject(:extracted_url) { extracted_metadata[:url] }

before do
allow(Plek).to receive(:new).and_return(
instance_double(Plek, website_root: "https://test.gov.uk"),
)
end

context "with a base_path" do
let(:document_hash) { { base_path: "/test" } }

it { is_expected.to eq("https://test.gov.uk/test") }
it { is_expected.to eq("https://www.gov.uk/test") }
end

context "with an external URL" do
Expand All @@ -84,7 +78,7 @@
{ base_path: "/test", details: { url: "https://liverpool.gov.uk/" } }
end

it { is_expected.to eq("https://test.gov.uk/test") }
it { is_expected.to eq("https://www.gov.uk/test") }
end

context "without a base_path or external URL" do
Expand Down

0 comments on commit 6381386

Please sign in to comment.