# allowed_values = values & ([""] + (filter_options[:values] || []).collect {|val| val[1]})
# filters[field] = {:operator => operator, :values => allowed_values } if (allowed_values.first and !allowed_values.first.empty?) or ["o", "c", "!*", "*", "t"].include? operator
#end
- filters[field] = {:operator => operator, :values => (values || ['']) }
+ values ||= ['']
+ if filter_options[:type] == :integer
+ values = values.select {|v| v.blank? || v.match(/^\d+(\.\d+)?$/) }
+ end
+ filters[field] = {:operator => operator, :values => values }
end
end
find_issues_with_query(query)
end
+ def test_numeric_filter_should_not_accept_non_numeric_values
+ query = Query.new(:name => '_')
+ query.add_filter('estimated_hours', '=', ['a'])
+
+ assert query.has_filter?('estimated_hours')
+ assert query.values_for('estimated_hours').empty?
+ assert !query.valid?
+ end
+
def test_operator_is_on_float
Issue.update_all("estimated_hours = 171.2", "id=2")