fix(api_entreprise): don't fail with entreprise without date_creation

This commit is contained in:
Colin Darie 2022-09-05 15:52:06 +02:00
parent ad13690d4d
commit be965e4fdd
2 changed files with 13 additions and 1 deletions

View file

@ -10,7 +10,7 @@ class APIEntreprise::EntrepriseAdapter < APIEntreprise::Adapter
params[:etat_administratif] = map_etat_administratif(data_source)
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}" }
else
{}

View file

@ -72,6 +72,18 @@ describe APIEntreprise::EntrepriseAdapter do
expect(subject[:entreprise_etat_administratif]).to eq('actif')
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
context "when the SIRET is unknown" do