2022-09-26 11:45:52 +02:00
|
|
|
describe SerializerService do
|
2024-07-01 15:31:32 +02:00
|
|
|
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :siret }]) }
|
|
|
|
let(:dossier) { create(:dossier, :en_construction, :with_populated_champs, procedure:) }
|
|
|
|
let(:champ) { dossier.champs.first }
|
|
|
|
let(:etablissement) { champ.etablissement }
|
2022-09-26 11:45:52 +02:00
|
|
|
|
|
|
|
describe 'champ' do
|
|
|
|
subject { SerializerService.champ(champ) }
|
|
|
|
|
|
|
|
describe 'type champ is siret' do
|
|
|
|
it {
|
|
|
|
is_expected.to include("stringValue" => etablissement.siret)
|
|
|
|
expect(subject["etablissement"]).to include("siret" => etablissement.siret)
|
|
|
|
expect(subject["etablissement"]["entreprise"]).to include("codeEffectifEntreprise" => etablissement.entreprise_code_effectif_entreprise)
|
|
|
|
}
|
|
|
|
|
|
|
|
context 'with entreprise_date_creation is nil' do
|
2024-07-01 15:31:32 +02:00
|
|
|
before { etablissement.update(entreprise_date_creation: nil) }
|
2022-09-26 11:45:52 +02:00
|
|
|
|
|
|
|
it {
|
|
|
|
expect(subject["etablissement"]["entreprise"]).to include("nomCommercial" => etablissement.entreprise_nom_commercial)
|
|
|
|
expect(subject["etablissement"]["entreprise"]["dateCreation"]).to be_nil
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|