fix(api_entreprise): don't fail with entreprise without date_creation
This commit is contained in:
parent
ad13690d4d
commit
be965e4fdd
2 changed files with 13 additions and 1 deletions
|
@ -10,7 +10,7 @@ class APIEntreprise::EntrepriseAdapter < APIEntreprise::Adapter
|
||||||
params[:etat_administratif] = map_etat_administratif(data_source)
|
params[:etat_administratif] = map_etat_administratif(data_source)
|
||||||
|
|
||||||
if params.present? && valid_params?(params)
|
if params.present? && valid_params?(params)
|
||||||
params[:date_creation] = Time.zone.at(params[:date_creation]).to_datetime
|
params[:date_creation] = Time.zone.at(params[:date_creation]).to_datetime if params[:date_creation].present?
|
||||||
params.transform_keys { |k| :"entreprise_#{k}" }
|
params.transform_keys { |k| :"entreprise_#{k}" }
|
||||||
else
|
else
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -72,6 +72,18 @@ describe APIEntreprise::EntrepriseAdapter do
|
||||||
expect(subject[:entreprise_etat_administratif]).to eq('actif')
|
expect(subject[:entreprise_etat_administratif]).to eq('actif')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when date_creation is empty" do
|
||||||
|
let(:body) do
|
||||||
|
hash = JSON.parse(super())
|
||||||
|
hash["entreprise"]["date_creation"] = nil
|
||||||
|
JSON.generate(hash)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'L\'entreprise ne contient pas de date_creation' do
|
||||||
|
expect(subject[:entreprise_date_creation]).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the SIRET is unknown" do
|
context "when the SIRET is unknown" do
|
||||||
|
|
Loading…
Reference in a new issue