summaryrefslogtreecommitdiffstats
path: root/test/unit/query_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-12-05 20:45:45 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-12-05 20:45:45 +0000
commit5ca558f19177472cd17f0b5e72e649845c301ae7 (patch)
tree83ede372e6d07e3ae10e3efb4ad6113c37da9b03 /test/unit/query_test.rb
parentc562d79e4fb12c44693e50c815ed0d1cc822ab78 (diff)
downloadredmine-5ca558f19177472cd17f0b5e72e649845c301ae7.tar.gz
redmine-5ca558f19177472cd17f0b5e72e649845c301ae7.zip
Fixed: error when filtering by numeric custom field with postgresql (#9719).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8098 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/query_test.rb')
-rw-r--r--test/unit/query_test.rb39
1 files changed, 35 insertions, 4 deletions
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index f298dd59f..1980018a5 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -147,6 +147,32 @@ class QueryTest < ActiveSupport::TestCase
assert_equal 2, issues.first.id
end
+ def test_operator_is_on_integer_custom_field
+ 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'])
+ 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')
+ 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'])
+ issues = find_issues_with_query(query)
+ assert_equal 1, issues.size
+ assert_equal 2, issues.first.id
+ end
+
def test_operator_greater_than
query = Query.new(:project => Project.find(1), :name => '_')
query.add_filter('done_ratio', '>=', ['40'])
@@ -161,12 +187,17 @@ class QueryTest < ActiveSupport::TestCase
find_issues_with_query(query)
end
- def test_operator_greater_than_on_custom_field
+ def test_operator_greater_than_on_int_custom_field
f = IssueCustomField.create!(:name => 'filter', :field_format => 'int', :is_filter => true, :is_for_all => 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(:project => Project.find(1), :name => '_')
- query.add_filter("cf_#{f.id}", '>=', ['40'])
- assert query.statement.include?("CAST(custom_values.value AS decimal(60,3)) >= 40.0")
- find_issues_with_query(query)
+ query.add_filter("cf_#{f.id}", '>=', ['8'])
+ issues = find_issues_with_query(query)
+ assert_equal 1, issues.size
+ assert_equal 2, issues.first.id
end
def test_operator_lesser_than