mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-13 23:37:47 +00:00
Replace country names with standard ISO code concepts
The DFC version 1.16.0 introduced this new standardisation.
This commit is contained in:
@@ -7,10 +7,17 @@ class AddressBuilder < DfcBuilder
|
||||
street: address.address1,
|
||||
postalCode: address.zipcode,
|
||||
city: address.city,
|
||||
country: address.country.name,
|
||||
country: country(address.country),
|
||||
region: address.state.name,
|
||||
latitude: address.latitude,
|
||||
longitude: address.longitude,
|
||||
)
|
||||
end
|
||||
|
||||
# The country has to be a value of:
|
||||
# https://publications.europa.eu/resource/authority/country/0001
|
||||
def self.country(spree_country)
|
||||
code = spree_country.iso3
|
||||
"http://publications.europa.eu/resource/authority/country/#{code}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,7 +33,8 @@ RSpec.describe AddressBuilder do
|
||||
end
|
||||
|
||||
it "assigns a country" do
|
||||
expect(result.country).to eq "Australia"
|
||||
expect(result.country)
|
||||
.to eq "http://publications.europa.eu/resource/authority/country/AUS"
|
||||
end
|
||||
|
||||
it "assigns a region" do
|
||||
|
||||
@@ -63,7 +63,7 @@ paths:
|
||||
dfc-b:hasStreet: 10 Lovely Street
|
||||
dfc-b:hasPostalCode: '20170'
|
||||
dfc-b:hasCity: Herndon
|
||||
dfc-b:hasCountry: Australia
|
||||
dfc-b:hasCountry: http://publications.europa.eu/resource/authority/country/AUS
|
||||
dfc-b:region: Victoria
|
||||
'404':
|
||||
description: not found
|
||||
@@ -407,7 +407,7 @@ paths:
|
||||
dfc-b:hasStreet: 8 Acres Drive
|
||||
dfc-b:hasPostalCode: '20170'
|
||||
dfc-b:hasCity: Herndon
|
||||
dfc-b:hasCountry: Australia
|
||||
dfc-b:hasCountry: http://publications.europa.eu/resource/authority/country/AUS
|
||||
dfc-b:region: Victoria
|
||||
"/api/dfc/enterprises":
|
||||
get:
|
||||
@@ -463,14 +463,14 @@ paths:
|
||||
dfc-b:hasStreet: 42 Doveton Street
|
||||
dfc-b:hasPostalCode: '20170'
|
||||
dfc-b:hasCity: Herndon
|
||||
dfc-b:hasCountry: Australia
|
||||
dfc-b:hasCountry: http://publications.europa.eu/resource/authority/country/AUS
|
||||
dfc-b:region: Victoria
|
||||
- "@id": http://test.host/api/dfc/addresses/40000
|
||||
"@type": dfc-b:Address
|
||||
dfc-b:hasStreet: 42 Doveton Street
|
||||
dfc-b:hasPostalCode: '20170'
|
||||
dfc-b:hasCity: Herndon
|
||||
dfc-b:hasCountry: Australia
|
||||
dfc-b:hasCountry: http://publications.europa.eu/resource/authority/country/AUS
|
||||
dfc-b:latitude: -25.345376
|
||||
dfc-b:longitude: 131.0312006
|
||||
dfc-b:region: Victoria
|
||||
@@ -549,7 +549,7 @@ paths:
|
||||
dfc-b:hasStreet: 42 Doveton Street
|
||||
dfc-b:hasPostalCode: '20170'
|
||||
dfc-b:hasCity: Herndon
|
||||
dfc-b:hasCountry: Australia
|
||||
dfc-b:hasCountry: http://publications.europa.eu/resource/authority/country/AUS
|
||||
dfc-b:latitude: -25.345376
|
||||
dfc-b:longitude: 131.0312006
|
||||
dfc-b:region: Victoria
|
||||
|
||||
Reference in New Issue
Block a user