ProcedurePresentation: rescue big int as a datetime value

This commit is contained in:
simon lehericey 2018-10-26 14:23:11 +02:00 committed by Frederic Merizen
parent c5015291a6
commit a06f872a4b
2 changed files with 11 additions and 3 deletions

View file

@ -111,7 +111,7 @@ class ProcedurePresentation < ApplicationRecord
column = sanitized_column(filter)
case table
when 'self'
date = Time.zone.parse(filter['value'])
date = Time.zone.parse(filter['value']) rescue nil
if date.present?
dossiers.where("#{column} BETWEEN ? AND ?", date, date + 1.day)
else

View file

@ -406,8 +406,16 @@ describe ProcedurePresentation do
end
context 'for a malformed date' do
let(:filter) { [{ 'table' => 'self', 'column' => 'updated_at', 'value' => 'malformed date' }] }
it { is_expected.to match([]) }
context 'when its a string' do
let(:filter) { [{ 'table' => 'self', 'column' => 'updated_at', 'value' => 'malformed date' }] }
it { is_expected.to match([]) }
end
context 'when its a number' do
let(:filter) { [{ 'table' => 'self', 'column' => 'updated_at', 'value' => '177500' }] }
it { is_expected.to match([]) }
end
end
end