[fix #1000] export name and first name in api

This commit is contained in:
Simon Lehericey 2017-12-11 15:15:03 +01:00
parent c4498ece2b
commit b02282c1d0
5 changed files with 19 additions and 1 deletions

View file

@ -14,6 +14,7 @@ class DossierSerializer < ActiveModel::Serializer
:accompagnateurs,
:invites
has_one :individual
has_one :entreprise
has_one :etablissement
has_many :cerfa

View file

@ -0,0 +1,3 @@
class IndividualSerializer < ActiveModel::Serializer
attributes :nom, :prenom
end

View file

@ -58,6 +58,10 @@
"invites": [
"nom@domaine.fr"
],
"individual": {
"nom": "Monmari",
"prenom": "René"
},
"entreprise": {
"siren": "440117620",
"capital_social": 537100000,

View file

@ -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

View file

@ -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