[#1961] filtered_ids for individual

This commit is contained in:
Frederic Merizen 2018-10-11 11:17:58 +02:00
parent 34da620b0f
commit abd066c6f4
2 changed files with 25 additions and 1 deletions

View file

@ -129,7 +129,7 @@ class ProcedurePresentation < ApplicationRecord
.includes(table) .includes(table)
.where("#{column} ILIKE ?", "%#{filter['value']}%") .where("#{column} ILIKE ?", "%#{filter['value']}%")
end end
when 'user' when 'user', 'individual'
dossiers dossiers
.includes(table) .includes(table)
.where("#{column} ILIKE ?", "%#{filter['value']}%") .where("#{column} ILIKE ?", "%#{filter['value']}%")

View file

@ -382,5 +382,29 @@ describe ProcedurePresentation do
it { is_expected.to contain_exactly(kept_dossier.id) } it { is_expected.to contain_exactly(kept_dossier.id) }
end end
context 'for individual table' do
let(:procedure) { create(:procedure, :for_individual) }
let!(:kept_dossier) { create(:dossier, procedure: procedure, individual: create(:individual, gender: 'Mme', prenom: 'Josephine', nom: 'Baker')) }
let!(:discarded_dossier) { create(:dossier, procedure: procedure, individual: create(:individual, gender: 'M', prenom: 'Jean', nom: 'Tremblay')) }
context 'for gender column' do
let(:filter) { [{ 'table' => 'individual', 'column' => 'gender', 'value' => 'Mme' }] }
it { is_expected.to contain_exactly(kept_dossier.id) }
end
context 'for prenom column' do
let(:filter) { [{ 'table' => 'individual', 'column' => 'prenom', 'value' => 'Josephine' }] }
it { is_expected.to contain_exactly(kept_dossier.id) }
end
context 'for nom column' do
let(:filter) { [{ 'table' => 'individual', 'column' => 'nom', 'value' => 'Baker' }] }
it { is_expected.to contain_exactly(kept_dossier.id) }
end
end
end end
end end