summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-07-04 18:50:09 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-07-04 18:50:09 +0000
commitd00ba6d2bb7cd76edf2cd1e75584f9dfd336ea72 (patch)
treea6f46f2b589917d31d921f0a960001d2a518f159 /test
parent86617fc437887c6791f82eaefb3b675f51666ba9 (diff)
downloadredmine-d00ba6d2bb7cd76edf2cd1e75584f9dfd336ea72.tar.gz
redmine-d00ba6d2bb7cd76edf2cd1e75584f9dfd336ea72.zip
Fixed: Can't filter for negative numeric custom field (#11307).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9908 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/unit/query_test.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index cba83b7c0..61f7a4b01 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -179,6 +179,20 @@ class QueryTest < ActiveSupport::TestCase
assert_equal 2, issues.first.id
end
+ def test_operator_is_on_integer_custom_field_should_accept_negative_value
+ f = IssueCustomField.create!(:name => 'filter', :field_format => 'int', :is_for_all => true, :is_filter => true)
+ CustomValue.create!(:custom_field => f, :customized => Issue.find(1), :value => '7')
+ CustomValue.create!(:custom_field => f, :customized => Issue.find(2), :value => '-12')
+ CustomValue.create!(:custom_field => f, :customized => Issue.find(3), :value => '')
+
+ query = Query.new(:name => '_')
+ query.add_filter("cf_#{f.id}", '=', ['-12'])
+ assert query.valid?
+ issues = find_issues_with_query(query)
+ assert_equal 1, issues.size
+ assert_equal 2, issues.first.id
+ end
+
def test_operator_is_on_float_custom_field
f = IssueCustomField.create!(:name => 'filter', :field_format => 'float', :is_filter => true, :is_for_all => true)
CustomValue.create!(:custom_field => f, :customized => Issue.find(1), :value => '7.3')
@@ -192,6 +206,20 @@ class QueryTest < ActiveSupport::TestCase
assert_equal 2, issues.first.id
end
+ def test_operator_is_on_float_custom_field_should_accept_negative_value
+ f = IssueCustomField.create!(:name => 'filter', :field_format => 'float', :is_filter => true, :is_for_all => true)
+ CustomValue.create!(:custom_field => f, :customized => Issue.find(1), :value => '7.3')
+ CustomValue.create!(:custom_field => f, :customized => Issue.find(2), :value => '-12.7')
+ CustomValue.create!(:custom_field => f, :customized => Issue.find(3), :value => '')
+
+ query = Query.new(:name => '_')
+ query.add_filter("cf_#{f.id}", '=', ['-12.7'])
+ assert query.valid?
+ issues = find_issues_with_query(query)
+ assert_equal 1, issues.size
+ assert_equal 2, issues.first.id
+ end
+
def test_operator_is_on_multi_list_custom_field
f = IssueCustomField.create!(:name => 'filter', :field_format => 'list', :is_filter => true, :is_for_all => true,
:possible_values => ['value1', 'value2', 'value3'], :multiple => true)