Merge pull request #7808 from betagouv/fix-serializer-personne-morale-wo-date-creation
fix(graphql): PersonneMorale#date_creation may be null
This commit is contained in:
commit
72cc43a70e
4 changed files with 30 additions and 3 deletions
|
@ -1450,7 +1450,7 @@ type Entreprise {
|
||||||
"""
|
"""
|
||||||
capitalSocial: BigInt
|
capitalSocial: BigInt
|
||||||
codeEffectifEntreprise: String
|
codeEffectifEntreprise: String
|
||||||
dateCreation: ISO8601Date!
|
dateCreation: ISO8601Date
|
||||||
|
|
||||||
"""
|
"""
|
||||||
effectif moyen d’une année
|
effectif moyen d’une année
|
||||||
|
|
|
@ -22,7 +22,7 @@ module Types
|
||||||
field :code_effectif_entreprise, String, null: true
|
field :code_effectif_entreprise, String, null: true
|
||||||
field :effectif_mensuel, EffectifType, null: true, description: "effectif pour un mois donné"
|
field :effectif_mensuel, EffectifType, null: true, description: "effectif pour un mois donné"
|
||||||
field :effectif_annuel, EffectifType, null: true, description: "effectif moyen d’une année"
|
field :effectif_annuel, EffectifType, null: true, description: "effectif moyen d’une année"
|
||||||
field :date_creation, GraphQL::Types::ISO8601Date, null: false
|
field :date_creation, GraphQL::Types::ISO8601Date, null: true
|
||||||
field :etat_administratif, EntrepriseEtatAdministratifType, null: true
|
field :etat_administratif, EntrepriseEtatAdministratifType, null: true
|
||||||
field :nom, String, null: true
|
field :nom, String, null: true
|
||||||
field :prenom, String, null: true
|
field :prenom, String, null: true
|
||||||
|
|
|
@ -19,7 +19,7 @@ class Entreprise < Hashie::Dash
|
||||||
property :effectif_mensuel
|
property :effectif_mensuel
|
||||||
property :effectif_annuel
|
property :effectif_annuel
|
||||||
property :effectif_annuel_annee
|
property :effectif_annuel_annee
|
||||||
property :date_creation
|
property :date_creation, default: nil
|
||||||
property :nom, default: nil
|
property :nom, default: nil
|
||||||
property :prenom, default: nil
|
property :prenom, default: nil
|
||||||
|
|
||||||
|
|
27
spec/services/serializer_service_spec.rb
Normal file
27
spec/services/serializer_service_spec.rb
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
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
|
Loading…
Add table
Reference in a new issue