2017-12-11 15:15:03 +01:00
|
|
|
describe IndividualSerializer do
|
|
|
|
describe '#attributes' do
|
2019-08-26 15:27:43 +02:00
|
|
|
let(:procedure) { create(:procedure) }
|
|
|
|
let(:dossier) { create(:dossier, procedure: procedure) }
|
|
|
|
let(:individual) { create(:individual, gender: 'M.', nom: 'nom', prenom: 'prenom', birthdate: Date.new(2001, 8, 27), dossier: dossier) }
|
2017-12-11 15:15:03 +01:00
|
|
|
|
|
|
|
subject { IndividualSerializer.new(individual).serializable_hash }
|
|
|
|
|
2018-05-30 15:25:16 +02:00
|
|
|
it { is_expected.to include(civilite: 'M.') }
|
2017-12-11 15:15:03 +01:00
|
|
|
it { is_expected.to include(nom: 'nom') }
|
|
|
|
it { is_expected.to include(prenom: 'prenom') }
|
2018-05-30 15:25:16 +02:00
|
|
|
it { is_expected.not_to have_key(:date_naissance) }
|
|
|
|
|
|
|
|
context 'when the procedure asks for a birthdate' do
|
2019-08-26 15:27:43 +02:00
|
|
|
before { procedure.update(ask_birthday: true) }
|
2018-05-30 15:25:16 +02:00
|
|
|
|
|
|
|
it { is_expected.to include(date_naissance: Date.new(2001, 8, 27)) }
|
|
|
|
end
|
2017-12-11 15:15:03 +01:00
|
|
|
end
|
|
|
|
end
|