diff --git a/app/services/dossier_filter_service.rb b/app/services/dossier_filter_service.rb index ce32fefc2..b8bdb3d81 100644 --- a/app/services/dossier_filter_service.rb +++ b/app/services/dossier_filter_service.rb @@ -90,6 +90,8 @@ class DossierFilterService dossiers.joins(:corrections).where(corrections: DossierCorrection.pending) elsif filtered_column.column == "state" && values.include?("en_construction") dossiers.where("dossiers.#{column} IN (?)", values).includes(:corrections).where.not(corrections: DossierCorrection.pending) + elsif filtered_column.type == :integer + dossiers.where("dossiers.#{column} IN (?)", values.filter_map { Integer(_1) rescue nil }) else dossiers.where("dossiers.#{column} IN (?)", values) end diff --git a/spec/services/dossier_filter_service_spec.rb b/spec/services/dossier_filter_service_spec.rb index 2290aad8c..5aac6d289 100644 --- a/spec/services/dossier_filter_service_spec.rb +++ b/spec/services/dossier_filter_service_spec.rb @@ -766,5 +766,11 @@ describe DossierFilterService do end end end + + context 'with a buggy filter, for instance a text in a integer column' do + let(:filter) { ['Nº dossier', 'buggy'] } + + it { is_expected.to be_empty } + end end end