Make #to_params return blank hashes if we have no data
This commit is contained in:
parent
0022ea71c5
commit
caf2e50954
6 changed files with 7 additions and 7 deletions
|
@ -10,7 +10,7 @@ class ApiEntreprise::EntrepriseAdapter
|
|||
params[:date_creation] = Time.at(params[:date_creation]).to_datetime
|
||||
params
|
||||
else
|
||||
nil
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class ApiEntreprise::EtablissementAdapter
|
|||
params[:adresse] = adresse_line
|
||||
params
|
||||
else
|
||||
nil
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class ApiEntreprise::RNAAdapter
|
|||
params[:rna] = data_source[:association][:id]
|
||||
params
|
||||
else
|
||||
nil
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ class SIRETService
|
|||
|
||||
params = etablissement_params
|
||||
.merge(entreprise_params.transform_keys { |k| "entreprise_#{k}" })
|
||||
.merge((association_params || {}).transform_keys { |k| "association_#{k}" })
|
||||
.merge(association_params.transform_keys { |k| "association_#{k}" })
|
||||
.merge(exercices_attributes: exercices_array)
|
||||
|
||||
# This is to fill legacy models and relationships
|
||||
|
@ -19,7 +19,7 @@ class SIRETService
|
|||
params[:entreprise_attributes] = entreprise_params.merge(
|
||||
{
|
||||
dossier: dossier,
|
||||
rna_information_attributes: association_params
|
||||
rna_information_attributes: association_params.presence
|
||||
}.compact
|
||||
)
|
||||
end
|
||||
|
|
|
@ -79,6 +79,6 @@ describe ApiEntreprise::EtablissementAdapter do
|
|||
.to_return(body: 'Fake body', status: 404)
|
||||
end
|
||||
|
||||
it { expect(subject).to be_nil }
|
||||
it { expect(subject).to eq({}) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ describe ApiEntreprise::RNAAdapter do
|
|||
let(:body) { '' }
|
||||
let(:status) { '404' }
|
||||
|
||||
it { is_expected.to eq(nil) }
|
||||
it { is_expected.to eq({}) }
|
||||
end
|
||||
|
||||
it { expect(subject).to be_an_instance_of(Hash) }
|
||||
|
|
Loading…
Reference in a new issue