Merge pull request #11086 from demarches-simplifiees/fix_crashing_filtering
ETQ Instructeur, je n'ai plus de crash lorsque je filtre une colonne numérique avec un texte
This commit is contained in:
commit
7932085976
2 changed files with 8 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue