Merge pull request #9520 from demarches-simplifiees/filter-instructeur-exclude-en-attente-ldu

[instructeur] je veux pouvoir filtrer les dossiers "en construction" sans avoir ceux "en attente de corrections"
This commit is contained in:
Colin Darie 2023-09-27 11:57:35 +00:00 committed by GitHub
commit 2cc2c9f77d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View file

@ -209,6 +209,8 @@ class ProcedurePresentation < ApplicationRecord
dossiers.filter_by_datetimes(column, dates)
elsif field['column'] == "state" && values.include?("pending_correction")
dossiers.joins(:corrections).where(corrections: DossierCorrection.pending)
elsif field['column'] == "state" && values.include?("en_construction")
dossiers.where("dossiers.#{column} IN (?)", values).includes(:corrections).where.not(corrections: DossierCorrection.pending)
else
dossiers.where("dossiers.#{column} IN (?)", values)
end

View file

@ -565,6 +565,21 @@ describe ProcedurePresentation do
is_expected.to contain_exactly(kept_dossier.id, other_kept_dossier.id)
end
end
context 'with en_construction state filters' do
let(:filter) do
[
{ 'table' => 'self', 'column' => 'state', 'value' => 'en_construction' }
]
end
let!(:en_construction) { create(:dossier, :en_construction, procedure: procedure) }
let!(:en_construction_with_correction) { create(:dossier, :en_construction, procedure: procedure) }
let!(:correction) { create(:dossier_correction, dossier: en_construction_with_correction) }
it 'excludes dossier en construction with pending correction' do
is_expected.to contain_exactly(en_construction.id)
end
end
end
context 'for type_de_champ table' do