@@ -278,7 +278,11 class Query < ActiveRecord::Base | |||||
278 | # allowed_values = values & ([""] + (filter_options[:values] || []).collect {|val| val[1]}) |
|
278 | # allowed_values = values & ([""] + (filter_options[:values] || []).collect {|val| val[1]}) | |
279 | # filters[field] = {:operator => operator, :values => allowed_values } if (allowed_values.first and !allowed_values.first.empty?) or ["o", "c", "!*", "*", "t"].include? operator |
|
279 | # filters[field] = {:operator => operator, :values => allowed_values } if (allowed_values.first and !allowed_values.first.empty?) or ["o", "c", "!*", "*", "t"].include? operator | |
280 | #end |
|
280 | #end | |
281 | filters[field] = {:operator => operator, :values => (values || ['']) } |
|
281 | values ||= [''] | |
|
282 | if filter_options[:type] == :integer | |||
|
283 | values = values.select {|v| v.blank? || v.match(/^\d+(\.\d+)?$/) } | |||
|
284 | end | |||
|
285 | filters[field] = {:operator => operator, :values => values } | |||
282 | end |
|
286 | end | |
283 | end |
|
287 | end | |
284 |
|
288 |
@@ -101,6 +101,15 class QueryTest < ActiveSupport::TestCase | |||||
101 | find_issues_with_query(query) |
|
101 | find_issues_with_query(query) | |
102 | end |
|
102 | end | |
103 |
|
103 | |||
|
104 | def test_numeric_filter_should_not_accept_non_numeric_values | |||
|
105 | query = Query.new(:name => '_') | |||
|
106 | query.add_filter('estimated_hours', '=', ['a']) | |||
|
107 | ||||
|
108 | assert query.has_filter?('estimated_hours') | |||
|
109 | assert query.values_for('estimated_hours').empty? | |||
|
110 | assert !query.valid? | |||
|
111 | end | |||
|
112 | ||||
104 | def test_operator_is_on_float |
|
113 | def test_operator_is_on_float | |
105 | Issue.update_all("estimated_hours = 171.2", "id=2") |
|
114 | Issue.update_all("estimated_hours = 171.2", "id=2") | |
106 |
|
115 |
General Comments 0
You need to be logged in to leave comments.
Login now