Merge pull request #7833 from betagouv/fix_filter_on_multiple_state

fix(instructeur dashboard): permets de filtrer les dossiers sur plusieurs états
This commit is contained in:
LeSim 2022-10-03 15:47:33 +02:00 committed by GitHub
commit a90c8ae02b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View file

@ -182,7 +182,7 @@ class ProcedurePresentation < ApplicationRecord
dossiers.filter_by_datetimes(column, dates)
else
dossiers.where("dossiers.#{column} = ?", values)
dossiers.where("dossiers.#{column} IN (?)", values)
end
when TYPE_DE_CHAMP
dossiers.with_type_de_champ(column)

View file

@ -487,6 +487,23 @@ describe ProcedurePresentation do
is_expected.to contain_exactly(kept_dossier.id, other_kept_dossier.id)
end
end
context 'with multiple state filters' do
let(:filter) do
[
{ 'table' => 'self', 'column' => 'state', 'value' => 'en_construction' },
{ 'table' => 'self', 'column' => 'state', 'value' => 'en_instruction' }
]
end
let!(:kept_dossier) { create(:dossier, :en_construction, procedure: procedure) }
let!(:other_kept_dossier) { create(:dossier, :en_instruction, procedure: procedure) }
let!(:discarded_dossier) { create(:dossier, :accepte, procedure: procedure) }
it 'returns every dossier that matches any of the search criteria for a given column' do
is_expected.to contain_exactly(kept_dossier.id, other_kept_dossier.id)
end
end
end
context 'for type_de_champ table' do