Merge pull request #9128 from colinux/fix-procedure-presentation-show-avis
ETQ instructeur je veux pouvoir afficher sans erreur la colonne "avis"
This commit is contained in:
commit
66dc8f251f
2 changed files with 22 additions and 0 deletions
|
@ -163,6 +163,11 @@ class ProcedurePresentation < ApplicationRecord
|
|||
.order("instructeurs_users.email #{order}")
|
||||
.pluck(:id)
|
||||
.uniq
|
||||
when 'avis'
|
||||
dossiers.includes(table)
|
||||
.order("#{self.class.sanitized_column(table, column)} #{order}")
|
||||
.pluck(:id)
|
||||
.uniq
|
||||
when 'self', 'user', 'individual', 'etablissement', 'groupe_instructeur'
|
||||
(table == 'self' ? dossiers : dossiers.includes(table))
|
||||
.order("#{self.class.sanitized_column(table, column)} #{order}")
|
||||
|
|
|
@ -382,6 +382,23 @@ describe ProcedurePresentation do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for avis table' do
|
||||
let(:table) { 'avis' }
|
||||
let(:column) { 'answer' }
|
||||
let(:order) { 'asc' }
|
||||
|
||||
let!(:dossier_yes) { create(:dossier, procedure:) }
|
||||
let!(:dossier_no) { create(:dossier, procedure:) }
|
||||
|
||||
before do
|
||||
create_list(:avis, 2, dossier: dossier_yes, question_answer: true)
|
||||
create(:avis, dossier: dossier_no, question_answer: true)
|
||||
create(:avis, dossier: dossier_no, question_answer: false)
|
||||
end
|
||||
|
||||
it { is_expected.to eq([dossier_yes, dossier_no].map(&:id)) }
|
||||
end
|
||||
|
||||
context 'for other tables' do
|
||||
# All other columns and tables work the same so it’s ok to test only one
|
||||
let(:table) { 'etablissement' }
|
||||
|
|
Loading…
Reference in a new issue