summaryrefslogtreecommitdiffstats
path: root/test/unit/query_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-02-20 13:03:32 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-02-20 13:03:32 +0000
commitf357912d211cc588921e2cc34a8f529d066656c6 (patch)
tree94509c927edefed894c25ef4bc07d193c91d995a /test/unit/query_test.rb
parent329b2aa2630860796196d71404c8d82d2e6e9223 (diff)
downloadredmine-f357912d211cc588921e2cc34a8f529d066656c6.tar.gz
redmine-f357912d211cc588921e2cc34a8f529d066656c6.zip
Fixed: SQL error when filtering issues with an empty group or role (#7656).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4888 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/query_test.rb')
-rw-r--r--test/unit/query_test.rb34
1 files changed, 32 insertions, 2 deletions
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index 4d85a2b2b..ce4306441 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -484,7 +484,6 @@ class QueryTest < ActiveSupport::TestCase
# Users not in a group
assert_query_statement_includes @query, "#{Issue.table_name}.assigned_to_id IS NULL OR #{Issue.table_name}.assigned_to_id NOT IN ('#{@user_in_group.id}','#{@second_user_in_group.id}','#{@user_in_group2.id}')"
assert_find_issues_with_query_is_successful @query
-
end
should "search assigned to any group member (all)" do
@@ -494,7 +493,22 @@ class QueryTest < ActiveSupport::TestCase
# Only users in a group
assert_query_statement_includes @query, "#{Issue.table_name}.assigned_to_id IN ('#{@user_in_group.id}','#{@second_user_in_group.id}','#{@user_in_group2.id}')"
assert_find_issues_with_query_is_successful @query
-
+ end
+
+ should "return an empty set with = empty group" do
+ @empty_group = Group.generate!
+ @query = Query.new(:name => '_')
+ @query.add_filter('member_of_group', '=', [@empty_group.id.to_s])
+
+ assert_equal [], find_issues_with_query(@query)
+ end
+
+ should "return issues with ! empty group" do
+ @empty_group = Group.generate!
+ @query = Query.new(:name => '_')
+ @query.add_filter('member_of_group', '!', [@empty_group.id.to_s])
+
+ assert_find_issues_with_query_is_successful @query
end
end
@@ -540,6 +554,22 @@ class QueryTest < ActiveSupport::TestCase
assert_query_statement_includes @query, "#{Issue.table_name}.assigned_to_id IN ('#{@manager.id}','#{@developer.id}','#{@boss.id}')"
assert_find_issues_with_query_is_successful @query
end
+
+ should "return an empty set with empty role" do
+ @empty_role = Role.generate!
+ @query = Query.new(:name => '_')
+ @query.add_filter('assigned_to_role', '=', [@empty_role.id.to_s])
+
+ assert_equal [], find_issues_with_query(@query)
+ end
+
+ should "return issues with ! empty role" do
+ @empty_role = Role.generate!
+ @query = Query.new(:name => '_')
+ @query.add_filter('member_of_group', '!', [@empty_role.id.to_s])
+
+ assert_find_issues_with_query_is_successful @query
+ end
end
end