Merge pull request #9003 from tchak/fix-dossiers-suivis-filter
ETQ Instructeur, je ne veux pas voir les dossiers terminés dans l'onglet "suivis"
This commit is contained in:
commit
e38c6ed73d
2 changed files with 31 additions and 12 deletions
|
@ -432,8 +432,8 @@ class Dossier < ApplicationRecord
|
||||||
when 'suivis'
|
when 'suivis'
|
||||||
instructeur
|
instructeur
|
||||||
.followed_dossiers
|
.followed_dossiers
|
||||||
.en_cours
|
|
||||||
.merge(visible_by_administration)
|
.merge(visible_by_administration)
|
||||||
|
.en_cours
|
||||||
when 'traites'
|
when 'traites'
|
||||||
visible_by_administration.termine
|
visible_by_administration.termine
|
||||||
when 'tous'
|
when 'tous'
|
||||||
|
|
|
@ -829,15 +829,33 @@ describe ProcedurePresentation do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#filtered_sorted_ids' do
|
describe '#filtered_sorted_ids' do
|
||||||
|
let(:procedure_presentation) { create(:procedure_presentation, assign_to:) }
|
||||||
let(:dossier_1) { create(:dossier) }
|
let(:dossier_1) { create(:dossier) }
|
||||||
let(:dossier_2) { create(:dossier) }
|
let(:dossier_2) { create(:dossier) }
|
||||||
let(:dossier_3) { create(:dossier) }
|
let(:dossier_3) { create(:dossier) }
|
||||||
let(:dossiers) { Dossier.where(id: [dossier_1, dossier_2, dossier_3].map(&:id)) }
|
let(:dossiers) { Dossier.where(id: [dossier_1, dossier_2, dossier_3].map(&:id)) }
|
||||||
|
|
||||||
let(:sorted_ids) { [dossier_2, dossier_3, dossier_1].map(&:id) }
|
let(:sorted_ids) { [dossier_2, dossier_3, dossier_1].map(&:id) }
|
||||||
|
let(:statut) { 'tous' }
|
||||||
|
|
||||||
subject { procedure_presentation.filtered_sorted_ids(dossiers, 'tous') }
|
subject { procedure_presentation.filtered_sorted_ids(dossiers, statut) }
|
||||||
|
|
||||||
|
context 'with no filters' do
|
||||||
|
let(:statut) { 'suivis' }
|
||||||
|
let(:dossiers) { procedure.dossiers }
|
||||||
|
|
||||||
|
before do
|
||||||
|
create(:follow, dossier: en_construction_dossier, instructeur: procedure_presentation.instructeur)
|
||||||
|
create(:follow, dossier: accepte_dossier, instructeur: procedure_presentation.instructeur)
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:en_construction_dossier) { create(:dossier, :en_construction, procedure:) }
|
||||||
|
let(:accepte_dossier) { create(:dossier, :accepte, procedure:) }
|
||||||
|
|
||||||
|
it { is_expected.to contain_exactly(en_construction_dossier.id) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with mocked sorted_ids' do
|
||||||
before do
|
before do
|
||||||
expect(procedure_presentation).to receive(:sorted_ids).and_return(sorted_ids)
|
expect(procedure_presentation).to receive(:sorted_ids).and_return(sorted_ids)
|
||||||
end
|
end
|
||||||
|
@ -855,6 +873,7 @@ describe ProcedurePresentation do
|
||||||
it { is_expected.to eq(sorted_ids) }
|
it { is_expected.to eq(sorted_ids) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#field_enum' do
|
describe '#field_enum' do
|
||||||
context "field is groupe_instructeur" do
|
context "field is groupe_instructeur" do
|
||||||
|
|
Loading…
Reference in a new issue