diff --git a/app/validators/routes_and_redirects_validator.rb b/app/validators/routes_and_redirects_validator.rb index a79156d72..a967982ff 100644 --- a/app/validators/routes_and_redirects_validator.rb +++ b/app/validators/routes_and_redirects_validator.rb @@ -103,10 +103,7 @@ def validate(record, attribute, route, base_path) def below_base_path?(path, base_path) return true if path =~ %r{^#{base_path}\.[\w-]+\z} - suffix = /\.([\w-]+\z)$/.match(base_path).to_a&.first || "" - base_path_without_suffix = base_path.gsub(suffix, "") - - /^#{base_path_without_suffix}.*#{suffix}/.match?(path) + /^#{base_path}/.match?(path) end def segments(path) diff --git a/content_schemas/dist/formats/worldwide_office/frontend/schema.json b/content_schemas/dist/formats/worldwide_office/frontend/schema.json index 27dc254f0..8195c9bcf 100644 --- a/content_schemas/dist/formats/worldwide_office/frontend/schema.json +++ b/content_schemas/dist/formats/worldwide_office/frontend/schema.json @@ -306,9 +306,6 @@ "change_history": { "$ref": "#/definitions/change_history" }, - "contact_content_id": { - "$ref": "#/definitions/guid" - }, "services": { "type": "array", "items": { @@ -333,13 +330,6 @@ }, "uniqueItems": true }, - "slug": { - "type": "string", - "format": "uri" - }, - "title": { - "type": "string" - }, "type": { "description": "The type of Worldwide Office.", "type": [ diff --git a/content_schemas/dist/formats/worldwide_office/notification/schema.json b/content_schemas/dist/formats/worldwide_office/notification/schema.json index cbef9a68f..721f77f53 100644 --- a/content_schemas/dist/formats/worldwide_office/notification/schema.json +++ b/content_schemas/dist/formats/worldwide_office/notification/schema.json @@ -405,9 +405,6 @@ "change_history": { "$ref": "#/definitions/change_history" }, - "contact_content_id": { - "$ref": "#/definitions/guid" - }, "services": { "type": "array", "items": { @@ -432,13 +429,6 @@ }, "uniqueItems": true }, - "slug": { - "type": "string", - "format": "uri" - }, - "title": { - "type": "string" - }, "type": { "description": "The type of Worldwide Office.", "type": [ diff --git a/content_schemas/dist/formats/worldwide_office/publisher_v2/schema.json b/content_schemas/dist/formats/worldwide_office/publisher_v2/schema.json index 189f67371..b69b38773 100644 --- a/content_schemas/dist/formats/worldwide_office/publisher_v2/schema.json +++ b/content_schemas/dist/formats/worldwide_office/publisher_v2/schema.json @@ -177,9 +177,6 @@ "null" ] }, - "contact_content_id": { - "$ref": "#/definitions/guid" - }, "services": { "type": "array", "items": { @@ -204,13 +201,6 @@ }, "uniqueItems": true }, - "slug": { - "type": "string", - "format": "uri" - }, - "title": { - "type": "string" - }, "type": { "description": "The type of Worldwide Office.", "type": [ diff --git a/content_schemas/dist/formats/worldwide_organisation/frontend/schema.json b/content_schemas/dist/formats/worldwide_organisation/frontend/schema.json index 2afd1bacc..c699d8ee1 100644 --- a/content_schemas/dist/formats/worldwide_organisation/frontend/schema.json +++ b/content_schemas/dist/formats/worldwide_organisation/frontend/schema.json @@ -341,63 +341,6 @@ "default_news_image": { "$ref": "#/definitions/image" }, - "home_page_office_parts": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "access_and_opening_times": { - "description": "The access and opening times for this Worldwide Office.", - "type": [ - "string", - "null" - ] - }, - "contact_content_id": { - "$ref": "#/definitions/guid" - }, - "services": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "title": { - "description": "The name of the service provided by this Worldwide Office.", - "type": [ - "string", - "null" - ] - }, - "type": { - "description": "The type of service provided by this Worldwide Office.", - "type": [ - "string", - "null" - ] - } - } - }, - "uniqueItems": true - }, - "slug": { - "type": "string", - "format": "uri" - }, - "title": { - "type": "string" - }, - "type": { - "description": "The type of Worldwide Office.", - "type": [ - "string", - "null" - ] - } - } - } - }, "logo": { "description": "The organisation's logo, including the logo image and formatted name.", "type": "object", @@ -430,63 +373,6 @@ } } }, - "main_office_parts": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "access_and_opening_times": { - "description": "The access and opening times for this Worldwide Office.", - "type": [ - "string", - "null" - ] - }, - "contact_content_id": { - "$ref": "#/definitions/guid" - }, - "services": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "title": { - "description": "The name of the service provided by this Worldwide Office.", - "type": [ - "string", - "null" - ] - }, - "type": { - "description": "The type of service provided by this Worldwide Office.", - "type": [ - "string", - "null" - ] - } - } - }, - "uniqueItems": true - }, - "slug": { - "type": "string", - "format": "uri" - }, - "title": { - "type": "string" - }, - "type": { - "description": "The type of Worldwide Office.", - "type": [ - "string", - "null" - ] - } - } - } - }, "office_contact_associations": { "type": "array", "items": { diff --git a/content_schemas/dist/formats/worldwide_organisation/notification/schema.json b/content_schemas/dist/formats/worldwide_organisation/notification/schema.json index d790a221d..97def50c2 100644 --- a/content_schemas/dist/formats/worldwide_organisation/notification/schema.json +++ b/content_schemas/dist/formats/worldwide_organisation/notification/schema.json @@ -476,63 +476,6 @@ "default_news_image": { "$ref": "#/definitions/image" }, - "home_page_office_parts": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "access_and_opening_times": { - "description": "The access and opening times for this Worldwide Office.", - "type": [ - "string", - "null" - ] - }, - "contact_content_id": { - "$ref": "#/definitions/guid" - }, - "services": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "title": { - "description": "The name of the service provided by this Worldwide Office.", - "type": [ - "string", - "null" - ] - }, - "type": { - "description": "The type of service provided by this Worldwide Office.", - "type": [ - "string", - "null" - ] - } - } - }, - "uniqueItems": true - }, - "slug": { - "type": "string", - "format": "uri" - }, - "title": { - "type": "string" - }, - "type": { - "description": "The type of Worldwide Office.", - "type": [ - "string", - "null" - ] - } - } - } - }, "logo": { "description": "The organisation's logo, including the logo image and formatted name.", "type": "object", @@ -565,63 +508,6 @@ } } }, - "main_office_parts": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "access_and_opening_times": { - "description": "The access and opening times for this Worldwide Office.", - "type": [ - "string", - "null" - ] - }, - "contact_content_id": { - "$ref": "#/definitions/guid" - }, - "services": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "title": { - "description": "The name of the service provided by this Worldwide Office.", - "type": [ - "string", - "null" - ] - }, - "type": { - "description": "The type of service provided by this Worldwide Office.", - "type": [ - "string", - "null" - ] - } - } - }, - "uniqueItems": true - }, - "slug": { - "type": "string", - "format": "uri" - }, - "title": { - "type": "string" - }, - "type": { - "description": "The type of Worldwide Office.", - "type": [ - "string", - "null" - ] - } - } - } - }, "office_contact_associations": { "type": "array", "items": { diff --git a/content_schemas/dist/formats/worldwide_organisation/publisher_v2/schema.json b/content_schemas/dist/formats/worldwide_organisation/publisher_v2/schema.json index 7399986ba..e2c3c75f8 100644 --- a/content_schemas/dist/formats/worldwide_organisation/publisher_v2/schema.json +++ b/content_schemas/dist/formats/worldwide_organisation/publisher_v2/schema.json @@ -224,63 +224,6 @@ "default_news_image": { "$ref": "#/definitions/image" }, - "home_page_office_parts": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "access_and_opening_times": { - "description": "The access and opening times for this Worldwide Office.", - "type": [ - "string", - "null" - ] - }, - "contact_content_id": { - "$ref": "#/definitions/guid" - }, - "services": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "title": { - "description": "The name of the service provided by this Worldwide Office.", - "type": [ - "string", - "null" - ] - }, - "type": { - "description": "The type of service provided by this Worldwide Office.", - "type": [ - "string", - "null" - ] - } - } - }, - "uniqueItems": true - }, - "slug": { - "type": "string", - "format": "uri" - }, - "title": { - "type": "string" - }, - "type": { - "description": "The type of Worldwide Office.", - "type": [ - "string", - "null" - ] - } - } - } - }, "logo": { "description": "The organisation's logo, including the logo image and formatted name.", "type": "object", @@ -313,63 +256,6 @@ } } }, - "main_office_parts": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "access_and_opening_times": { - "description": "The access and opening times for this Worldwide Office.", - "type": [ - "string", - "null" - ] - }, - "contact_content_id": { - "$ref": "#/definitions/guid" - }, - "services": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "title": { - "description": "The name of the service provided by this Worldwide Office.", - "type": [ - "string", - "null" - ] - }, - "type": { - "description": "The type of service provided by this Worldwide Office.", - "type": [ - "string", - "null" - ] - } - } - }, - "uniqueItems": true - }, - "slug": { - "type": "string", - "format": "uri" - }, - "title": { - "type": "string" - }, - "type": { - "description": "The type of Worldwide Office.", - "type": [ - "string", - "null" - ] - } - } - } - }, "office_contact_associations": { "type": "array", "items": { diff --git a/content_schemas/examples/worldwide_organisation/frontend/worldwide_organisation.json b/content_schemas/examples/worldwide_organisation/frontend/worldwide_organisation.json index 7b02f16fd..141004541 100644 --- a/content_schemas/examples/worldwide_organisation/frontend/worldwide_organisation.json +++ b/content_schemas/examples/worldwide_organisation/frontend/worldwide_organisation.json @@ -21,48 +21,6 @@ "url": "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/default_news_organisation_image_data/file/548/s300_fcdo-main-building.jpg", "high_resolution_url": "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/default_news_organisation_image_data/file/548/s960_fcdo-main-building.jpg" }, - "home_page_office_parts": [ - { - "access_and_opening_times": "Our opening times", - "contact_content_id": "53df7197-901c-48fc-b9b4-ed649903f1f0", - "services": [ - { - "title": "Business Funding", - "type": "Business Funds" - }, - { - "title": "Business Advice", - "type": "Business Advisory" - } - ], - "slug": "office/uk-trade-investment-duesseldorf", - "title": "Department for Business and Trade Dusseldorf", - "type": "Department for Business and Trade Office" - }, - { - "access_and_opening_times": "Our opening times", - "contact_content_id": "d7196415-647c-4b81-8e9f-8436c53e45f0", - "services": [], - "slug": "office/uk-trade-investment-munich", - "title": "Department for Business and Trade Munich", - "type": "Department for Business and Trade Office" - } - ], - "main_office_parts": [ - { - "access_and_opening_times": "Our opening times", - "contact_content_id": "410c4c3b-5c1c-4617-b603-4356bedcc85e", - "services": [ - { - "title": "Emergency Travel Documents service", - "type": "Assistance Services" - } - ], - "slug": "office/british-embassy", - "title": "British Embassy", - "type": "Embassy" - } - ], "office_contact_associations": [ { "office_content_id": "58c83be0-6264-4cb0-a652-126d57e8c0b7", diff --git a/content_schemas/formats/shared/definitions/_worldwide_office.jsonnet b/content_schemas/formats/shared/definitions/_worldwide_office.jsonnet deleted file mode 100644 index 9771ab002..000000000 --- a/content_schemas/formats/shared/definitions/_worldwide_office.jsonnet +++ /dev/null @@ -1,54 +0,0 @@ -{ - type: "object", - additionalProperties: false, - properties: { - access_and_opening_times: { - type: [ - "string", - "null", - ], - description: "The access and opening times for this Worldwide Office.", - }, - contact_content_id: { - "$ref": "#/definitions/guid", - }, - services: { - type: "array", - uniqueItems: true, - items: { - type: "object", - additionalProperties: false, - properties: { - title: { - type: [ - "string", - "null", - ], - description: "The name of the service provided by this Worldwide Office.", - }, - type: { - type: [ - "string", - "null", - ], - description: "The type of service provided by this Worldwide Office.", - } - } - } - }, - slug: { - type: "string", - format: "uri", - }, - title: { - type: "string", - }, - type: { - type: [ - "string", - "null", - ], - description: "The type of Worldwide Office.", - }, - } -} diff --git a/content_schemas/formats/worldwide_office.jsonnet b/content_schemas/formats/worldwide_office.jsonnet index 63f6eb847..768ba4cc5 100644 --- a/content_schemas/formats/worldwide_office.jsonnet +++ b/content_schemas/formats/worldwide_office.jsonnet @@ -1,7 +1,50 @@ (import "shared/default_format.jsonnet") + { document_type: "worldwide_office", definitions: (import "shared/definitions/_whitehall.jsonnet") + { - details: (import "shared/definitions/_worldwide_office.jsonnet"), + details: { + type: "object", + additionalProperties: false, + properties: { + access_and_opening_times: { + type: [ + "string", + "null", + ], + description: "The access and opening times for this Worldwide Office.", + }, + type: { + type: [ + "string", + "null", + ], + description: "The type of Worldwide Office.", + }, + services: { + type: "array", + uniqueItems: true, + items: { + type: "object", + additionalProperties: false, + properties: { + title: { + type: [ + "string", + "null", + ], + description: "The name of the service provided by this Worldwide Office.", + }, + type: { + type: [ + "string", + "null", + ], + description: "The type of service provided by this Worldwide Office.", + } + } + } + }, + }, + }, }, links: (import "shared/base_links.jsonnet") + { contact: "Contact details for this Worldwide Office", diff --git a/content_schemas/formats/worldwide_organisation.jsonnet b/content_schemas/formats/worldwide_organisation.jsonnet index 913a3775c..a6cf8723e 100644 --- a/content_schemas/formats/worldwide_organisation.jsonnet +++ b/content_schemas/formats/worldwide_organisation.jsonnet @@ -12,14 +12,6 @@ default_news_image: { "$ref": "#/definitions/image", }, - "home_page_office_parts": { - "type": "array", - "items": (import "shared/definitions/_worldwide_office.jsonnet"), - }, - "main_office_parts": { - "type": "array", - "items": (import "shared/definitions/_worldwide_office.jsonnet"), - }, office_contact_associations: { type: "array", items: { diff --git a/spec/support/routes_and_redirects_validator.rb b/spec/support/routes_and_redirects_validator.rb index 993942ead..0d1ed0238 100644 --- a/spec/support/routes_and_redirects_validator.rb +++ b/spec/support/routes_and_redirects_validator.rb @@ -19,30 +19,6 @@ expect(subject).to be_valid end - describe "with nested translated routes" do - let(:edition) { build(:edition, base_path: "/vat-rates.fr") } - - it "is valid when a translated route is below the base path" do - edition.routes = [ - { path: "/vat-rates.fr", type: "exact" }, - { path: "/vat-rates/path/document.fr", type: "exact" }, - ] - - expect(subject).to be_valid - end - - it "is invalid when a translated route is below the base path but has the wrong translation" do - edition.routes = [ - { path: "/vat-rates.fr", type: "exact" }, - { path: "/vat-rates/path/document.fr", type: "exact" }, - { path: "/vat-rates/path/document.es", type: "exact" }, - ] - - expect(subject).to be_invalid - expect(subject.errors[:routes]).to eq(["path must be below the base path"]) - end - end - it "must have unique paths" do edition.routes = [ { path: subject.base_path, type: "exact" },