diff --git a/app/serializers/dossier_serializer.rb b/app/serializers/dossier_serializer.rb index 3cb69bbde..9de70e415 100644 --- a/app/serializers/dossier_serializer.rb +++ b/app/serializers/dossier_serializer.rb @@ -14,6 +14,7 @@ class DossierSerializer < ActiveModel::Serializer :accompagnateurs, :invites + has_one :individual has_one :entreprise has_one :etablissement has_many :cerfa diff --git a/app/serializers/individual_serializer.rb b/app/serializers/individual_serializer.rb new file mode 100644 index 000000000..b35e01892 --- /dev/null +++ b/app/serializers/individual_serializer.rb @@ -0,0 +1,3 @@ +class IndividualSerializer < ActiveModel::Serializer + attributes :nom, :prenom +end diff --git a/doc/apipie_examples.json b/doc/apipie_examples.json index e8573dcad..229529ce4 100644 --- a/doc/apipie_examples.json +++ b/doc/apipie_examples.json @@ -58,6 +58,10 @@ "invites": [ "nom@domaine.fr" ], + "individual": { + "nom": "Monmari", + "prenom": "René" + }, "entreprise": { "siren": "440117620", "capital_social": 537100000, diff --git a/spec/controllers/api/v1/dossiers_controller_spec.rb b/spec/controllers/api/v1/dossiers_controller_spec.rb index 58c49bb29..98fb7b4d4 100644 --- a/spec/controllers/api/v1/dossiers_controller_spec.rb +++ b/spec/controllers/api/v1/dossiers_controller_spec.rb @@ -115,7 +115,7 @@ describe API::V1::DossiersController do let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure, motivation: "Motivation") } } let(:dossier_id) { dossier.id } let(:body) { JSON.parse(retour.body, symbolize_names: true) } - let(:field_list) { [:id, :created_at, :updated_at, :archived, :mandataire_social, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :champs_private, :commentaires, :state, :simplified_state, :initiated_at, :processed_at, :received_at, :motivation, :email, :accompagnateurs, :invites] } + let(:field_list) { [:id, :created_at, :updated_at, :archived, :mandataire_social, :individual, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :champs_private, :commentaires, :state, :simplified_state, :initiated_at, :processed_at, :received_at, :motivation, :email, :accompagnateurs, :invites] } subject { body[:dossier] } it 'return REST code 200', :show_in_doc do diff --git a/spec/serializers/individual_serializer_spec.rb b/spec/serializers/individual_serializer_spec.rb new file mode 100644 index 000000000..f86b801a2 --- /dev/null +++ b/spec/serializers/individual_serializer_spec.rb @@ -0,0 +1,10 @@ +describe IndividualSerializer do + describe '#attributes' do + let(:individual){ Individual.create(nom: 'nom', prenom: 'prenom') } + + subject { IndividualSerializer.new(individual).serializable_hash } + + it { is_expected.to include(nom: 'nom') } + it { is_expected.to include(prenom: 'prenom') } + end +end