feat(rnf): also store rnf title
This commit is contained in:
parent
4b740f8f29
commit
a9237bf7f1
3 changed files with 25 additions and 15 deletions
|
@ -16,7 +16,7 @@ class Champs::RNFChamp < Champ
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_with_external_data!(data:)
|
def update_with_external_data!(data:)
|
||||||
update!(data:, value_json: APIGeoService.parse_rnf_address(data[:address]))
|
update!(data:, value_json: extract_value_json(data:))
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_external_data?
|
def fetch_external_data?
|
||||||
|
@ -109,4 +109,11 @@ class Champs::RNFChamp < Champ
|
||||||
address['label']
|
address['label']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def extract_value_json(data:)
|
||||||
|
h = APIGeoService.parse_rnf_address(data[:address])
|
||||||
|
h.merge(title: data[:title])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -102,18 +102,19 @@ describe Champs::RNFChamp, type: :model do
|
||||||
describe 'update_with_external_data!' do
|
describe 'update_with_external_data!' do
|
||||||
it 'works' do
|
it 'works' do
|
||||||
value_json = {
|
value_json = {
|
||||||
:street_number => "16",
|
street_number: "16",
|
||||||
:street_name => "Rue du Général de Boissieu",
|
street_name: "Rue du Général de Boissieu",
|
||||||
:street_address => "16 Rue du Général de Boissieu",
|
street_address: "16 Rue du Général de Boissieu",
|
||||||
:postal_code => "75015",
|
postal_code: "75015",
|
||||||
:city_name => "Paris 15e Arrondissement",
|
city_name: "Paris 15e Arrondissement",
|
||||||
:city_code => "75115",
|
city_code: "75115",
|
||||||
:departement_code => "75",
|
departement_code: "75",
|
||||||
:department_code => "75",
|
department_code: "75",
|
||||||
:departement_name => "Paris",
|
departement_name: "Paris",
|
||||||
:department_name => "Paris",
|
department_name: "Paris",
|
||||||
:region_code => "11",
|
region_code: "11",
|
||||||
:region_name => "Île-de-France"
|
region_name: "Île-de-France",
|
||||||
|
title: "Fondation SFR"
|
||||||
}
|
}
|
||||||
expect(champ).to receive(:update!).with(data: anything, value_json:)
|
expect(champ).to receive(:update!).with(data: anything, value_json:)
|
||||||
champ.update_with_external_data!(data: subject.value!)
|
champ.update_with_external_data!(data: subject.value!)
|
||||||
|
|
|
@ -66,7 +66,8 @@ module Maintenance
|
||||||
"departement_name" => "Paris",
|
"departement_name" => "Paris",
|
||||||
"department_name" => "Paris",
|
"department_name" => "Paris",
|
||||||
"region_code" => "11",
|
"region_code" => "11",
|
||||||
"region_name" => "Île-de-France"
|
"region_name" => "Île-de-France",
|
||||||
|
"title" => "Fondation SFR"
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -92,7 +93,8 @@ module Maintenance
|
||||||
"departement_name" => "Paris",
|
"departement_name" => "Paris",
|
||||||
"department_name" => "Paris",
|
"department_name" => "Paris",
|
||||||
"region_code" => "11",
|
"region_code" => "11",
|
||||||
"region_name" => "Île-de-France"
|
"region_name" => "Île-de-France",
|
||||||
|
"title" => "Fondation SFR"
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue