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:
Colin Darie 2023-06-05 08:53:39 +00:00 committed by GitHub
commit 66dc8f251f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View file

@ -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}")

View file

@ -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 its ok to test only one
let(:table) { 'etablissement' }