feat(etablissement): save value json data for columns
This commit is contained in:
parent
a400045964
commit
f1d14bd6af
3 changed files with 24 additions and 4 deletions
|
@ -211,7 +211,12 @@ class Etablissement < ApplicationRecord
|
|||
end
|
||||
|
||||
def champ_value_json
|
||||
APIGeoService.parse_etablissement_address(self)
|
||||
address_data = APIGeoService.parse_etablissement_address(self)
|
||||
|
||||
DISPLAYABLE_COLUMNS.keys.each_with_object(address_data) do |attr, hash|
|
||||
value = public_send(attr)
|
||||
hash[attr.to_sym] = value if value.present?
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -152,10 +152,18 @@ describe Etablissement do
|
|||
etablissement.champ = champ
|
||||
end
|
||||
|
||||
it 'updates the associated champ value_json with geocoded address' do
|
||||
subject(:value_json) {
|
||||
etablissement.update_champ_value_json!
|
||||
champ.reload.value_json
|
||||
}
|
||||
|
||||
expect(champ.reload.value_json).to eq(address_data)
|
||||
it 'updates the associated champ value_json with geocoded address' do
|
||||
expect(value_json).to include(address_data.stringify_keys)
|
||||
end
|
||||
|
||||
it 'includes jsonpathables columns entreprise attributes' do
|
||||
expect(value_json["entreprise_siren"]).to eq(etablissement.siren)
|
||||
expect(value_json["entreprise_raison_sociale"]).to eq(etablissement.entreprise_raison_sociale)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -29,7 +29,14 @@ module Maintenance
|
|||
"departement_code" => "92",
|
||||
"department_code" => "92",
|
||||
"departement_name" => "Hauts-de-Seine",
|
||||
"department_name" => "Hauts-de-Seine"
|
||||
"department_name" => "Hauts-de-Seine",
|
||||
|
||||
"entreprise_date_creation" => "1990-04-24",
|
||||
"entreprise_forme_juridique" => "SA à conseil d'administration (s.a.i.)",
|
||||
"entreprise_nom_commercial" => "GRTGAZ",
|
||||
"entreprise_raison_sociale" => "GRTGAZ",
|
||||
"entreprise_siren" => "440117620",
|
||||
"libelle_naf" => "Transports par conduites"
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue