[#1961] get_value for individual
This commit is contained in:
parent
5d862ae92b
commit
34da620b0f
2 changed files with 25 additions and 4 deletions
|
@ -186,10 +186,8 @@ class ProcedurePresentation < ApplicationRecord
|
|||
case table
|
||||
when 'self'
|
||||
dossier.send(column)
|
||||
when 'user'
|
||||
dossier.user.send(column)
|
||||
when 'etablissement'
|
||||
dossier.etablissement&.send(column)
|
||||
when 'user', 'individual', 'etablissement'
|
||||
dossier.send(table)&.send(column)
|
||||
when 'type_de_champ'
|
||||
dossier.champs.find { |c| c.type_de_champ_id == column.to_i }.value
|
||||
when 'type_de_champ_private'
|
||||
|
|
|
@ -147,6 +147,29 @@ describe ProcedurePresentation do
|
|||
it { is_expected.to eq('bla@yopmail.com') }
|
||||
end
|
||||
|
||||
context 'for individual table' do
|
||||
let(:table) { 'individual' }
|
||||
let(:dossier) { create(:dossier, procedure: procedure, individual: create(:individual, nom: 'Martin', prenom: 'Jacques', gender: 'M.')) }
|
||||
|
||||
context 'for prenom column' do
|
||||
let(:column) { 'prenom' }
|
||||
|
||||
it { is_expected.to eq('Jacques') }
|
||||
end
|
||||
|
||||
context 'for nom column' do
|
||||
let(:column) { 'nom' }
|
||||
|
||||
it { is_expected.to eq('Martin') }
|
||||
end
|
||||
|
||||
context 'for gender column' do
|
||||
let(:column) { 'gender' }
|
||||
|
||||
it { is_expected.to eq('M.') }
|
||||
end
|
||||
end
|
||||
|
||||
context 'for etablissement table' do
|
||||
let(:table) { 'etablissement' }
|
||||
let(:column) { 'code_postal' } # All other columns work the same, no extra test required
|
||||
|
|
Loading…
Reference in a new issue