diff --git a/app/models/procedure_presentation.rb b/app/models/procedure_presentation.rb index 7b5ac387f..82a26f1ae 100644 --- a/app/models/procedure_presentation.rb +++ b/app/models/procedure_presentation.rb @@ -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) diff --git a/spec/models/procedure_presentation_spec.rb b/spec/models/procedure_presentation_spec.rb index 213358568..361438c07 100644 --- a/spec/models/procedure_presentation_spec.rb +++ b/spec/models/procedure_presentation_spec.rb @@ -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