diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index efcfa99a..e14a4667 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -102,12 +102,6 @@ jobs:
with:
pact_artifact: pacts
- whitehall_pact:
- needs: generate_pacts
- uses: alphagov/whitehall/.github/workflows/pact-verify.yml@main
- with:
- pact_artifact: pacts
-
publish_pacts:
needs:
- account_api_pact
@@ -119,7 +113,6 @@ jobs:
- link_checker_api_pact
- locations_api_pact
- publishing_api_pact
- - whitehall_pact
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e0a35f2e..5e9d4bde 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 90.0.0
+
+* BREAKING: Change source for `GdsApi.worldwide.organisations_for_world_location` method, remove pagination and remove `stub_worldwide_api_has_organisations_for_location` method.
+
# 89.0.0
* BREAKING: Change source for `GdsApi.worldwide.world_locations` method and remove pagination.
diff --git a/lib/gds_api/test_helpers/worldwide.rb b/lib/gds_api/test_helpers/worldwide.rb
index 10baefc3..7645f063 100644
--- a/lib/gds_api/test_helpers/worldwide.rb
+++ b/lib/gds_api/test_helpers/worldwide.rb
@@ -52,18 +52,28 @@ def stub_worldwide_api_has_location(location_slug)
stub_worldwide_api_has_locations([location_slug])
end
- def stub_worldwide_api_has_organisations_for_location(location_slug, json_or_hash)
- json = json_or_hash.is_a?(Hash) ? json_or_hash.to_json : json_or_hash
- url = "#{WORLDWIDE_API_ENDPOINT}/api/world-locations/#{location_slug}/organisations"
- stub_request(:get, url)
- .to_return(status: 200, body: json, headers: { "Link" => "<#{url}; rel\"self\"" })
+ def stub_search_api_has_organisations_for_location(location_slug, organisation_content_items)
+ response = {
+ "results": organisation_content_items.map do |content_item|
+ {
+ "link": content_item["base_path"],
+ }
+ end,
+ }
+
+ stub_request(:get, "#{WORLDWIDE_API_ENDPOINT}/api/search.json?filter_format=worldwide_organisation&filter_world_locations=#{location_slug}")
+ .to_return(status: 200, body: response.to_json)
+
+ organisation_content_items.each do |content_item|
+ stub_content_store_has_worldwide_organisation(content_item)
+ end
end
- def stub_worldwide_api_has_no_organisations_for_location(location_slug)
- details = { "results" => [], "total" => 0, "_response_info" => { "status" => "ok" } }
- url = "#{WORLDWIDE_API_ENDPOINT}/api/world-locations/#{location_slug}/organisations"
- stub_request(:get, url)
- .to_return(status: 200, body: details.to_json, headers: { "Link" => "<#{url}; rel\"self\"" })
+ def stub_content_store_has_worldwide_organisation(content_item)
+ base_path = content_item["base_path"]
+
+ stub_request(:get, "#{WORLDWIDE_API_ENDPOINT}/api/content#{base_path}")
+ .to_return(status: 200, body: content_item.to_json)
end
end
end
diff --git a/lib/gds_api/version.rb b/lib/gds_api/version.rb
index e7d2e12f..ea2832ef 100644
--- a/lib/gds_api/version.rb
+++ b/lib/gds_api/version.rb
@@ -1,3 +1,3 @@
module GdsApi
- VERSION = "89.0.0".freeze
+ VERSION = "90.0.0".freeze
end
diff --git a/lib/gds_api/worldwide.rb b/lib/gds_api/worldwide.rb
index d6bf274b..bd739141 100644
--- a/lib/gds_api/worldwide.rb
+++ b/lib/gds_api/worldwide.rb
@@ -16,7 +16,11 @@ def world_location(location_slug)
end
def organisations_for_world_location(location_slug)
- get_list("#{base_url}/world-locations/#{location_slug}/organisations")
+ worldwide_organisations = worldwide_organisations_for_location(location_slug)
+
+ worldwide_organisations.map do |organisation|
+ worldwide_organisation(organisation["link"])
+ end
end
private
@@ -55,4 +59,87 @@ def format_locations(locations, type)
}
end
end
+
+ def worldwide_organisations_for_location(world_location)
+ search_results = JSON.parse(get_raw("#{base_url}/search.json?filter_format=worldwide_organisation&filter_world_locations=#{world_location}"))
+
+ search_results["results"]
+ end
+
+ def worldwide_organisation(path)
+ content_item = JSON.parse(get_raw("#{base_url}/content#{path}"))
+
+ {
+ "id" => "#{Plek.new.website_root}#{path}",
+ "title" => content_item["title"],
+ "format" => "Worldwide Organisation",
+ "updated_at" => content_item["updated_at"],
+ "web_url" => "#{Plek.new.website_root}#{path}",
+ "details" => {
+ "slug" => path.gsub("/world/organisations/", ""),
+ },
+ "analytics_identifier" => content_item["analytics_identifier"],
+ "offices" => {
+ "main" => format_office(content_item.dig("links", "main_office", 0)),
+ "other" => content_item.dig("links", "home_page_offices")&.map do |office|
+ format_office(office)
+ end || [],
+ },
+ "sponsors" => content_item.dig("links", "sponsoring_organisations")&.map do |sponsor|
+ format_sponsor(sponsor)
+ end || [],
+ }
+ end
+
+ def format_office(office)
+ return {} unless office
+
+ contact = office.dig("links", "contact", 0)
+
+ {
+ "title" => office["title"],
+ "format" => "World Office",
+ "updated_at" => office["public_updated_at"],
+ "web_url" => office["web_url"],
+ "details" => {
+ "email" => contact&.dig("details", "email_addresses"),
+ "description" => contact&.dig("details", "description"),
+ "contact_form_url" => contact&.dig("details", "contact_form_links"),
+ "access_and_opening_times" => office.dig("details", "access_and_opening_times"),
+ "type" => office.dig("details", "type"),
+ },
+ "address" => {
+ "adr" => {
+ "fn" => contact&.dig("details", "post_addresses", 0, "title"),
+ "street-address" => contact&.dig("details", "post_addresses", 0, "street_address"),
+ "postal-code" => contact&.dig("details", "post_addresses", 0, "postal_code"),
+ "locality" => contact&.dig("details", "post_addresses", 0, "locality"),
+ "region" => contact&.dig("details", "post_addresses", 0, "region"),
+ "country-name" => contact&.dig("details", "post_addresses", 0, "world_location"),
+ },
+ },
+ "contact_numbers" => contact&.dig("details", "phone_numbers")&.map do |phone_number|
+ {
+ "label" => phone_number["title"],
+ "number" => phone_number["number"],
+ }
+ end,
+ "services" => contact&.dig("details", "services")&.map do |service|
+ {
+ title: service["title"],
+ type: service["type"],
+ }
+ end,
+ }
+ end
+
+ def format_sponsor(sponsor)
+ {
+ "title" => sponsor["title"],
+ "web_url" => sponsor["web_url"],
+ "details" => {
+ "acronym" => sponsor.dig("details", "acronym"),
+ },
+ }
+ end
end
diff --git a/test/fixtures/world_organisations_australia.json b/test/fixtures/world_organisations_australia.json
deleted file mode 100644
index 208fa1ff..00000000
--- a/test/fixtures/world_organisations_australia.json
+++ /dev/null
@@ -1,490 +0,0 @@
-{
- "results": [
- {
- "id": "https://www.gov.uk/api/worldwide-organisations/uk-trade-investment-australia",
- "title": "UK Trade & Investment Australia",
- "format": "Worldwide Organisation",
- "updated_at": "2013-04-10T13:51:59+01:00",
- "web_url": "https://www.gov.uk/government/world/organisations/uk-trade-investment-australia",
- "details": {
- "slug": "uk-trade-investment-australia",
- "summary": "UK Trade & Investment (UKTI) helps UK-based companies succeed in the global economy. We also help overseas companies bring their high-quality investment to the UK’s dynamic economy.",
- "description": "
UKTI offers expertise and contacts through its extensive network of specialists in the UK, and in British embassies and other diplomatic offices around the world. We provide companies with the tools they require to be competitive on the world stage.
\n\n
Responsibilities
\n\n
UKTI in Australia helps companies in Britain increase their competitiveness through overseas trade in Australia. We also offer professional, authoritative and personalised assistance to help companies in Australia locate and expand in the UK.
\n\n
You can find out more about how we are increasing business with Australia.
",
- "services": ""
- },
- "offices": {
- "main": {
- "title": "UK Trade & Investment, Sydney",
- "format": "World Office",
- "updated_at": "2013-03-25T10:37:53+00:00",
- "details": {
- "email": "",
- "description": "",
- "contact_form_url": "",
- "type": "Other"
- },
- "address": {
- "adr": {
- "fn": "British Consulate",
- "street-address": "Level 16, Gateway Building\r\n1 Macquarie Place",
- "postal-code": "2000",
- "locality": "Sydney",
- "region": "New South Wales",
- "country-name": "Australia"
- },
- "label": {
- "value": "British Consulate\nLevel 16, Gateway Building\r\n1 Macquarie Place\nSydney New South Wales 2000\nAustralia"
- }
- },
- "contact_numbers": [
- {
- "label": "Switchboard",
- "number": "+61 (0) 2 9247 7521 "
- }
- ],
- "services": [ ]
- },
- "other": [
- {
- "title": "UK Trade & Investment Brisbane",
- "format": "World Office",
- "updated_at": "2013-03-25T10:37:53+00:00",
- "details": {
- "email": "",
- "description": "",
- "contact_form_url": "",
- "type": "Other"
- },
- "address": {
- "adr": {
- "fn": "British Consulate",
- "street-address": "Level 9, 100 Eagle Street",
- "postal-code": "4000",
- "locality": "Brisbane",
- "region": "Queensland",
- "country-name": "Australia"
- },
- "label": {
- "value": "British Consulate\nLevel 9, 100 Eagle Street\nBrisbane Queensland 4000\nAustralia"
- }
- },
- "contact_numbers": [
- {
- "label": "Switchboard",
- "number": "+61 (0) 7 3223 3200 "
- }
- ],
- "services": [ ]
- },
- {
- "title": "UK Trade & Investment Melbourne",
- "format": "World Office",
- "updated_at": "2013-03-25T10:37:53+00:00",
- "details": {
- "email": "",
- "description": "",
- "contact_form_url": "",
- "type": "Other"
- },
- "address": {
- "adr": {
- "fn": "British Consulate",
- "street-address": "17th Floor, 90 Collins Street",
- "postal-code": "",
- "locality": "Melbourne",
- "region": "Victoria",
- "country-name": "Australia"
- },
- "label": {
- "value": "British Consulate\n17th Floor, 90 Collins Street\nMelbourne Victoria \nAustralia"
- }
- },
- "contact_numbers": [
- {
- "label": "Switchboard",
- "number": "+61 (0) 3 9652 1600 "
- }
- ],
- "services": [ ]
- },
- {
- "title": "UK Trade & Investment Perth",
- "format": "World Office",
- "updated_at": "2013-03-25T10:37:53+00:00",
- "details": {
- "email": "",
- "description": "",
- "contact_form_url": "",
- "type": "Other"
- },
- "address": {
- "adr": {
- "fn": "British Consulate",
- "street-address": "Level 12, 251 Adelaide Terrace Perth",
- "postal-code": "",
- "locality": "Perth",
- "region": "Western Australia",
- "country-name": "Australia"
- },
- "label": {
- "value": "British Consulate\nLevel 12, 251 Adelaide Terrace Perth\nPerth Western Australia \nAustralia"
- }
- },
- "contact_numbers": [
- {
- "label": "Switchboard",
- "number": "+61 (0) 8 9224 4700 "
- }
- ],
- "services": [ ]
- },
- {
- "title": "Director of Investment, Australia and New Zealand",
- "format": "World Office",
- "updated_at": "2013-03-25T10:37:53+00:00",
- "details": {
- "email": "paul.webster@fco.gov.uk ",
- "description": "",
- "contact_form_url": "",
- "type": "Other"
- },
- "address": {
- "adr": {
- "fn": "Paul Webster",
- "street-address": "Level 16, Gateway Building\r\n1 Macquarie Place",
- "postal-code": "2000",
- "locality": "Sydney",
- "region": "New South Wales",
- "country-name": "Australia"
- },
- "label": {
- "value": "Paul Webster\nLevel 16, Gateway Building\r\n1 Macquarie Place\nSydney New South Wales 2000\nAustralia"
- }
- },
- "contact_numbers": [
- {
- "label": "Direct line",
- "number": "+61 (0)2 8247 2234"
- }
- ],
- "services": [ ]
- },
- {
- "title": "Head of Investment New South Wales, ACT and Western Australia",
- "format": "World Office",
- "updated_at": "2013-03-25T10:37:53+00:00",
- "details": {
- "email": "nicky.vandomburg@fco.gov.uk ",
- "description": "",
- "contact_form_url": "",
- "type": "Other"
- },
- "address": {
- "adr": {
- "fn": "Nicky van Domburg",
- "street-address": "Level 16, Gateway Building\r\n1 Macquarie Place",
- "postal-code": "2000",
- "locality": "Sydney",
- "region": "New South Wales",
- "country-name": "Australia"
- },
- "label": {
- "value": "Nicky van Domburg\nLevel 16, Gateway Building\r\n1 Macquarie Place\nSydney New South Wales 2000\nAustralia"
- }
- },
- "contact_numbers": [
- {
- "label": "Direct line",
- "number": "+61 (0)2 8247 2205"
- }
- ],
- "services": [ ]
- },
- {
- "title": "Head of Investment Victoria, South Australia, Tasmania",
- "format": "World Office",
- "updated_at": "2013-03-25T10:37:53+00:00",
- "details": {
- "email": "",
- "description": "",
- "contact_form_url": "",
- "type": "Other"
- },
- "address": {
- "adr": {
- "fn": "Majella Hamilton",
- "street-address": "17th Floor, 90 Collins Street",
- "postal-code": "",
- "locality": "Melbourne",
- "region": "Victoria",
- "country-name": "Australia"
- },
- "label": {
- "value": "Majella Hamilton\n17th Floor, 90 Collins Street\nMelbourne Victoria \nAustralia"
- }
- },
- "contact_numbers": [
- {
- "label": "Direct line",
- "number": "+61 (0)3 9652 1621"
- }
- ],
- "services": [ ]
- },
- {
- "title": "Head of Investment Queensland and Northern Territory & Head of Institutional Investment Australia and New Zealand",
- "format": "World Office",
- "updated_at": "2013-03-25T10:37:53+00:00",
- "details": {
- "email": "craig.o'kane@fco.gov.uk ",
- "description": "",
- "contact_form_url": "",
- "type": "Other"
- },
- "address": {
- "adr": {
- "fn": "Craig O'Kane",
- "street-address": "Level 9, 100 Eagle Street\r\n",
- "postal-code": "4000",
- "locality": "Brisbane",
- "region": "Queensland",
- "country-name": "Australia"
- },
- "label": {
- "value": "Craig O'Kane\nLevel 9, 100 Eagle Street\r\nBrisbane Queensland 4000\nAustralia"
- }
- },
- "contact_numbers": [
- {
- "label": "Direct line",
- "number": "+61 (0)7 3223 3205"
- }
- ],
- "services": [ ]
- }
- ]
- },
- "sponsors": [
- {
- "title": "UK Trade & Investment",
- "web_url": "https://www.gov.uk/government/organisations/uk-trade-investment",
- "details": {
- "acronym": "UKTI"
- }
- }
- ]
- },
- {
- "id": "https://www.gov.uk/api/worldwide-organisations/british-high-commission-canberra",
- "title": "British High Commission Canberra",
- "format": "Worldwide Organisation",
- "updated_at": "2013-03-25T06:21:38+00:00",
- "web_url": "https://www.gov.uk/government/world/organisations/british-high-commission-canberra",
- "details": {
- "slug": "british-high-commission-canberra",
- "summary": "The UK and Australia share a longstanding relationship, as both partners and allies. ",
- "description": "We represent the British government in its relations with the Australian government and present British policies to the Australian government and to Australians. We report and explain Australian policies to the British government and support British interests as well as co-ordinating the political, economic, environmental and commercial activities of the British government.
\n\n
We have consulate-generals in Sydney and Melbourne and consulates in Brisbane and Perth. With over one million Britons living in Australia and over 640,000 visiting every year, the consulates support British nationals if they require assistance.
",
- "services": "\n
For information on whether you require a visa for the United Kingdom and how to apply go to the UK Border Agency website
\n\n
\n
Information on how you can register a birth or death which occurred overseas, and legal documents for couples marrying or entering into civil partnerships abroad.
\n\n
\n
How to renew or replace your British passport when visiting the UK and information on getting replacement travel documents if your passport is lost or stolen.
\n\n
\n
Information on staying safe and avoiding problems when living or travelling abroad, with links to our embassies, high commissions and other diplomatic posts across the world.
"
- },
- "offices": {
- "main": {
- "title": "British High Commission Canberra",
- "format": "World Office",
- "updated_at": "2013-03-25T10:37:54+00:00",
- "details": {
- "email": "",
- "description": "Opening Hours:\r\nMonday to Friday, 8.45am to 12.30pm/1.30pm to 5.00pm",
- "contact_form_url": "",
- "type": "High Commission"
- },
- "address": {
- "adr": {
- "fn": "High Commissioner: His Excellency Paul Madden",
- "street-address": "Commonwealth Avenue, Yarralumla",
- "postal-code": "2600",
- "locality": "Canberra",
- "region": "ACT",
- "country-name": "Australia"
- },
- "label": {
- "value": "High Commissioner: His Excellency Paul Madden\nCommonwealth Avenue, Yarralumla\nCanberra ACT 2600\nAustralia"
- }
- },
- "contact_numbers": [
- {
- "label": "Telephone:",
- "number": "+61 (0)2 6270 6666"
- }
- ],
- "services": [ ]
- },
- "other": [
- {
- "title": "British Consulate-General Sydney",
- "format": "World Office",
- "updated_at": "2013-03-25T10:37:54+00:00",
- "details": {
- "email": "",
- "description": "Opening Hours:\r\nMonday to Friday: 9.00am to 12.30pm/1.30pm to 5.00pm\r\nConsular counter hours:\r\nMonday to Friday 9.00am to 1.00pm\r\nSwitchboard hours:\r\nMonday to Friday 9.00am to 5.00pm",
- "contact_form_url": "",
- "type": "Consulate"
- },
- "address": {
- "adr": {
- "fn": "Consul-General and Director General UK Trade & Investment: Mr Nick McInnes",
- "street-address": "Level 16, Gateway Building, 1 Macquarie Place",
- "postal-code": "2000",
- "locality": "Sydney",
- "region": "NSW",
- "country-name": "Australia"
- },
- "label": {
- "value": "Consul-General and Director General UK Trade & Investment: Mr Nick McInnes\nLevel 16, Gateway Building, 1 Macquarie Place\nSydney NSW 2000\nAustralia"
- }
- },
- "contact_numbers": [
- {
- "label": "Telephone:",
- "number": "+61 (0) 9247 7521"
- }
- ],
- "services": [ ]
- },
- {
- "title": "British Consulate-General Melbourne",
- "format": "World Office",
- "updated_at": "2013-03-25T10:37:54+00:00",
- "details": {
- "email": "",
- "description": "Opening Hours:\r\nMonday to Friday 9.00am to 5.00pm \r\nPublic counter hours: \r\nMonday to Friday 10.00am to 2.00pm",
- "contact_form_url": "",
- "type": "Consulate"
- },
- "address": {
- "adr": {
- "fn": "Consul-General: Mr Gareth Hoar",
- "street-address": "17th Floor, 90 Collins St",
- "postal-code": "3000",
- "locality": "Melbourne",
- "region": "VIC",
- "country-name": "Australia"
- },
- "label": {
- "value": "Consul-General: Mr Gareth Hoar\n17th Floor, 90 Collins St\nMelbourne VIC 3000\nAustralia"
- }
- },
- "contact_numbers": [
- {
- "label": "Telephone:",
- "number": "+61 (0)3 9652 1600"
- }
- ],
- "services": [ ]
- },
- {
- "title": "British Consulate Perth",
- "format": "World Office",
- "updated_at": "2013-03-25T10:37:54+00:00",
- "details": {
- "email": "",
- "description": "Opening Hours Mondays to Fridays:\r\nPublic counter hours: 10.00am to 1.00pm\r\nUK Visa (biometric) appointments: 10.00am to 2.00pm\r\nSwitchboard hours: 9.00am to 4.30pm",
- "contact_form_url": "",
- "type": "Consulate"
- },
- "address": {
- "adr": {
- "fn": "Vice Consul and Head of Consular Services: Mr James Frew",
- "street-address": "Level 12\r\n251 Adelaide Terrace",
- "postal-code": "6000",
- "locality": "Perth",
- "region": "WA",
- "country-name": "Australia"
- },
- "label": {
- "value": "Vice Consul and Head of Consular Services: Mr James Frew\nLevel 12\r\n251 Adelaide Terrace\nPerth WA 6000\nAustralia"
- }
- },
- "contact_numbers": [
- {
- "label": "Telephone:",
- "number": "+61 (0)8 9224 4700"
- }
- ],
- "services": [
- {
- "title": "Emergency Travel Documents service",
- "type": "Assistance Services"
- },
- {
- "title": "Transferring funds for prisoners / for financial assistance service",
- "type": "Assistance Services"
- },
- {
- "title": "Marriage or Civil Partnership registrations",
- "type": "Documentary Services"
- },
- {
- "title": "Citizenship Ceremony service",
- "type": "Documentary Services"
- }
- ]
- },
- {
- "title": "British Consulate Brisbane",
- "format": "World Office",
- "updated_at": "2013-03-25T10:37:54+00:00",
- "details": {
- "email": "",
- "description": "Opening Hours Mondays to Fridays:\r\nCounter hours: 10.00am to 3.00pm\r\nSwitchboard hours: 9.30am to 4.30pm",
- "contact_form_url": "",
- "type": "Consulate"
- },
- "address": {
- "adr": {
- "fn": "Vice Consul and Head of Consular Services: Mrs Megan Hunt",
- "street-address": "Level 9\r\n100 Eagle Street \r\n",
- "postal-code": "4000",
- "locality": "Brisbane",
- "region": "QLD",
- "country-name": "Australia"
- },
- "label": {
- "value": "Vice Consul and Head of Consular Services: Mrs Megan Hunt\nLevel 9\r\n100 Eagle Street \r\nBrisbane QLD 4000\nAustralia"
- }
- },
- "contact_numbers": [
- {
- "label": "Telephone:",
- "number": "+61 (0)7 3223 3200"
- }
- ],
- "services": [ ]
- }
- ]
- },
- "sponsors": [
- {
- "title": "Foreign & Commonwealth Office",
- "web_url": "https://www.gov.uk/government/organisations/foreign-commonwealth-office",
- "details": {
- "acronym": "FCO"
- }
- }
- ]
- }
- ],
- "current_page": 1,
- "total": 2,
- "pages": 1,
- "page_size": 20,
- "start_index": 1,
- "_response_info": {
- "status": "ok",
- "links": [
- {
- "href": "https://www.gov.uk/api/world-locations/australia/organisations?page=1",
- "rel": "self"
- }
- ]
- }
-}
diff --git a/test/pacts/worldwide_api_pact_test.rb b/test/pacts/worldwide_api_pact_test.rb
deleted file mode 100644
index 1735e3d2..00000000
--- a/test/pacts/worldwide_api_pact_test.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-require "test_helper"
-require "gds_api/worldwide"
-
-describe "GdsApi::Worldwide pact tests" do
- include PactTest
-
- let(:api_client) { GdsApi::Worldwide.new(whitehall_api_host) }
-
- describe "#world_location" do
- describe "#organisations_for_world_location" do
- it "responds with 200 and all worldwide organisations" do
- whitehall_api
- .given("a worldwide organisation exists")
- .upon_receiving("a request to return a countries worldwide organisations")
- .with(
- method: :get,
- path: "/api/world-locations/france/organisations",
- headers: GdsApi::JsonClient.default_request_headers,
- )
- .will_respond_with(
- status: 200,
- body: {
- results: [
- Pact.like(
- id: "https://www.gov.uk/api/worldwide-organisations/british-embassy-paris",
- title: "British Embassy Paris",
- format: "Worldwide Organisation",
- updated_at: "2014-05-13T10:15:06.000+01:00",
- web_url: "https://www.gov.uk/world/organisations/british-embassy-paris",
- details: {
- slug: "british-embassy-paris",
- },
- analytics_identifier: "WO49",
- sponsors: [
- {
- title: "Foreign, Commonwealth & Development Office",
- web_url: "https://www.gov.uk/government/organisations/foreign-commonwealth-development-office",
- details: {
- acronym: "FCDO",
- },
- },
- ],
- ),
- ],
- },
- headers: {
- "Content-Type" => "application/json; charset=utf-8",
- },
- )
-
- api_client.organisations_for_world_location("france")
- end
- end
- end
-end
diff --git a/test/support/pact_helper.rb b/test/support/pact_helper.rb
index 9f13102a..2be0ab92 100644
--- a/test/support/pact_helper.rb
+++ b/test/support/pact_helper.rb
@@ -6,7 +6,6 @@
ACCOUNT_API_PORT = 3004
LINK_CHECKER_API_PORT = 3005
IMMINENCE_API_PORT = 3006
-WHITEHALL_API_PORT = 3007
LOCATIONS_API_PORT = 3008
ASSET_MANAGER_API_PORT = 3009
EMAIL_ALERT_API_PORT = 3010
@@ -35,10 +34,6 @@ def imminence_api_host
"http://localhost:#{IMMINENCE_API_PORT}"
end
-def whitehall_api_host
- "http://localhost:#{WHITEHALL_API_PORT}"
-end
-
def locations_api_host
"http://localhost:#{LOCATIONS_API_PORT}"
end
@@ -88,12 +83,6 @@ def email_alert_api_host
end
end
- has_pact_with "Whitehall API" do
- mock_service :whitehall_api do
- port WHITEHALL_API_PORT
- end
- end
-
has_pact_with "Locations API" do
mock_service :locations_api do
port LOCATIONS_API_PORT
diff --git a/test/worldwide_api_test.rb b/test/worldwide_api_test.rb
index 7f38d69d..a78f3351 100644
--- a/test/worldwide_api_test.rb
+++ b/test/worldwide_api_test.rb
@@ -40,25 +40,230 @@
describe "fetching organisations for a location" do
it "should return the organisation details" do
- details = JSON.parse(load_fixture_file("world_organisations_australia.json").read)
- stub_worldwide_api_has_organisations_for_location("australia", details)
+ content_items = [
+ {
+ "base_path" => "/world/organisations/uk-trade-investment-australia",
+ "title" => "UK Trade & Investment Australia",
+ "updated_at" => "2023-07-31 07:00:12",
+ "analytics_identifier" => "WO1",
+ "links" => {
+ "main_office" => [
+ {
+ "title" => "Australia Office",
+ "web_url" => "https://www.dev.gov.uk/world/offices/australia",
+ "public_updated_at" => "2023-07-30 07:00:12",
+ "details" => {
+ "access_and_opening_times" => "Open 9 to 5",
+ "type" => "Other office",
+ },
+ "links" => {
+ contact: [
+ {
+ "details" => {
+ "email_addresses" => "australia@gov.uk",
+ "description" => "An office in Australia",
+ "contact_form_links" => "https://www.gov.uk",
+ "post_addresses" => [
+ "title" => "Office Name",
+ "street_address" => "123 A Street",
+ "postal_code" => "ABC123",
+ "locality" => "Canberra",
+ "region" => "Australian Capital Territory",
+ "world_location" => "Australia",
+ ],
+ "phone_numbers" => [
+ "title" => "Office number",
+ "number" => "1234",
+ ],
+ "services" => [
+ {
+ "title" => "Trade advice",
+ "type" => "Advice",
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ ],
+ "home_page_offices" => [
+ {
+ "title" => "A second Australia Office",
+ "web_url" => "https://www.dev.gov.uk/world/offices/australia-2",
+ "public_updated_at" => "2023-07-30 07:00:12",
+ "details" => {
+ "access_and_opening_times" => "Open 9 to 5",
+ "type" => "Other office",
+ },
+ "links" => {
+ contact: [
+ {
+ "details" => {
+ "email_addresses" => "australia@gov.uk",
+ "description" => "An office in Australia",
+ "contact_form_links" => "https://www.gov.uk",
+ "post_addresses" => [
+ "title" => "Office Name",
+ "street_address" => "456 A Street",
+ "postal_code" => "ABC456",
+ "locality" => "Canberra",
+ "region" => "Australian Capital Territory",
+ "world_location" => "Australia",
+ ],
+ "phone_numbers" => [
+ "title" => "Office number",
+ "number" => "5678",
+ ],
+ "services" => [
+ {
+ "title" => "Trade advice",
+ "type" => "Advice",
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ ],
+ "sponsoring_organisations" => [
+ {
+ "title" => "Foreign, Commonwealth and Development Office",
+ "web_url" => "https://www.fcdo.gov.uk",
+ "details" => {
+ "acronym" => "FCDO",
+ },
+ },
+ ],
+ },
+ },
+ {
+ "base_path" => "/world/organisations/british-high-commission-canberra",
+ "title" => "British High Commission Canberra",
+ "updated_at" => "2023-07-31 09:00:12",
+ "analytics_identifier" => "WO2",
+ },
+ ]
+
+ stub_search_api_has_organisations_for_location("australia", content_items)
response = @api.organisations_for_world_location("australia")
- assert response.is_a?(GdsApi::ListResponse)
assert_equal(
[
- "UK Trade & Investment Australia",
- "British High Commission Canberra",
+ {
+ "id" => "#{Plek.new.website_root}/world/organisations/uk-trade-investment-australia",
+ "title" => "UK Trade & Investment Australia",
+ "format" => "Worldwide Organisation",
+ "updated_at" => "2023-07-31 07:00:12",
+ "web_url" => "#{Plek.new.website_root}/world/organisations/uk-trade-investment-australia",
+ "details" => {
+ "slug" => "uk-trade-investment-australia",
+ },
+ "analytics_identifier" => "WO1",
+ "offices" => {
+ "main" => {
+ "title" => "Australia Office",
+ "format" => "World Office",
+ "updated_at" => "2023-07-30 07:00:12",
+ "web_url" => "https://www.dev.gov.uk/world/offices/australia",
+ "details" => {
+ "email" => "australia@gov.uk",
+ "description" => "An office in Australia",
+ "contact_form_url" => "https://www.gov.uk",
+ "access_and_opening_times" => "Open 9 to 5",
+ "type" => "Other office",
+ },
+ "address" => {
+ "adr" => {
+ "fn" => "Office Name",
+ "street-address" => "123 A Street",
+ "postal-code" => "ABC123",
+ "locality" => "Canberra",
+ "region" => "Australian Capital Territory",
+ "country-name" => "Australia",
+ },
+ },
+ "contact_numbers" => [
+ {
+ "label" => "Office number",
+ "number" => "1234",
+ },
+ ],
+ "services" => [
+ {
+ title: "Trade advice",
+ type: "Advice",
+ },
+ ],
+ },
+ "other" => [
+ {
+ "title" => "A second Australia Office",
+ "format" => "World Office",
+ "updated_at" => "2023-07-30 07:00:12",
+ "web_url" => "https://www.dev.gov.uk/world/offices/australia-2",
+ "details" => {
+ "email" => "australia@gov.uk",
+ "description" => "An office in Australia",
+ "contact_form_url" => "https://www.gov.uk",
+ "access_and_opening_times" => "Open 9 to 5",
+ "type" => "Other office",
+ },
+ "address" => {
+ "adr" => {
+ "fn" => "Office Name",
+ "street-address" => "456 A Street",
+ "postal-code" => "ABC456",
+ "locality" => "Canberra",
+ "region" => "Australian Capital Territory",
+ "country-name" => "Australia",
+ },
+ },
+ "contact_numbers" => [
+ {
+ "label" => "Office number",
+ "number" => "5678",
+ },
+ ],
+ "services" => [
+ {
+ title: "Trade advice",
+ type: "Advice",
+ },
+ ],
+ },
+ ],
+ },
+ "sponsors" => [
+ {
+ "title" => "Foreign, Commonwealth and Development Office",
+ "web_url" => "https://www.fcdo.gov.uk",
+ "details" => {
+ "acronym" => "FCDO",
+ },
+ },
+ ],
+ },
+ {
+ "id" => "#{Plek.new.website_root}/world/organisations/british-high-commission-canberra",
+ "title" => "British High Commission Canberra",
+ "format" => "Worldwide Organisation",
+ "updated_at" => "2023-07-31 09:00:12",
+ "web_url" => "#{Plek.new.website_root}/world/organisations/british-high-commission-canberra",
+ "details" => {
+ "slug" => "british-high-commission-canberra",
+ },
+ "analytics_identifier" => "WO2",
+ "offices" => {
+ "main" => {},
+ "other" => [],
+ },
+ "sponsors" => [],
+ },
],
- response.map { |item| item["title"] },
+ response,
)
end
-
- it "should raise error on 404" do
- stub_request(:get, "#{@base_api_url}/api/world-locations/non-existent/organisations").to_return(status: 404)
- assert_raises GdsApi::HTTPNotFound do
- @api.organisations_for_world_location("non-existent")
- end
- end
end
end