Merge pull request #7722 from betagouv/fix-entreprise-without-date-creation

fix(api_entreprise job): don't fail with an entreprise without date_creation
This commit is contained in:
LeSim 2022-09-05 17:10:45 +02:00 committed by GitHub
commit 5268962797
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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