demarches-normaliennes/spec/services/serializer_service_spec.rb

28 lines
1 KiB
Ruby
Raw Normal View History

describe SerializerService do
let(:dossier) { create(:dossier, :en_construction) }
describe 'champ' do
subject { SerializerService.champ(champ) }
describe 'type champ is siret' do
let(:etablissement) { create(:etablissement) }
let(:champ) { create(:champ_siret, etablissement:, dossier:) }
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
let(:etablissement) { create(:etablissement, entreprise_date_creation: nil) }
it {
expect(subject["etablissement"]["entreprise"]).to include("nomCommercial" => etablissement.entreprise_nom_commercial)
expect(subject["etablissement"]["entreprise"]["dateCreation"]).to be_nil
}
end
end
end
end