summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2024-08-21 07:47:27 +0000
committerGo MAEDA <maeda@farend.jp>2024-08-21 07:47:27 +0000
commit643b4ebb088ce5ed57b6cc959677627a660004cc (patch)
treeb685620c7288a8ed3fa965faf558e17e3e120df4 /test
parent8c148bf6d02475cd027e0490ff1ef6ccbacc7bc1 (diff)
downloadredmine-643b4ebb088ce5ed57b6cc959677627a660004cc.tar.gz
redmine-643b4ebb088ce5ed57b6cc959677627a660004cc.zip
Add filters for "Author's group" and "Author's role" to issues list (#7867).
Patch by Takenori TAKAKI (user:takenory). git-svn-id: https://svn.redmine.org/redmine/trunk@22975 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/unit/query_test.rb60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index d26743cad..dd3b67928 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -2851,6 +2851,28 @@ class QueryTest < ActiveSupport::TestCase
assert ! query.available_filters["assigned_to_role"][:values].include?(['Anonymous', '5'])
end
+ def test_available_filters_should_include_author_group_filter
+ query = IssueQuery.new
+ assert query.available_filters.key?("author.group")
+ assert_equal :list, query.available_filters["author.group"][:type]
+ assert query.available_filters["author.group"][:values].present?
+ assert_equal Group.givable.sort.map {|g| [g.name, g.id.to_s]},
+ query.available_filters["author.group"][:values].sort
+ end
+
+ def test_available_filters_should_include_author_role_filter
+ query = IssueQuery.new
+ assert query.available_filters.key?("author.role")
+ assert_equal :list, query.available_filters["author.role"][:type]
+
+ assert query.available_filters["author.role"][:values].include?(['Manager', '1'])
+ assert query.available_filters["author.role"][:values].include?(['Developer', '2'])
+ assert query.available_filters["author.role"][:values].include?(['Reporter', '3'])
+
+ assert_not query.available_filters["author.role"][:values].include?(['Non member', '4'])
+ assert_not query.available_filters["author.role"][:values].include?(['Anonymous', '5'])
+ end
+
def test_available_filters_should_include_custom_field_according_to_user_visibility
visible_field = IssueCustomField.generate!(:is_for_all => true, :is_filter => true, :visible => true)
hidden_field = IssueCustomField.generate!(:is_for_all => true, :is_filter => true, :visible => false, :role_ids => [1])
@@ -3021,6 +3043,44 @@ class QueryTest < ActiveSupport::TestCase
assert_query_result [@issue1, @issue2, @issue3, @issue4, @issue5], @query
end
+ def test_author_group_filter_should_return_issues_with_or_without_author_in_group
+ project = Project.generate!
+ author = User.generate!
+ author_group = Group.generate!
+ not_author_group = Group.generate!
+ author.groups << author_group
+ issues = Array.new(3) { Issue.generate!(:project => project, :author => author) }
+
+ query = IssueQuery.new(:name => '_', :project => project)
+ query.add_filter('author_group', '=', [author_group.id.to_s])
+ assert_equal 3, query.issues.count
+ assert_query_result issues, query
+
+ query = IssueQuery.new(:name => '_', :project => project)
+ query.add_filter('author_group', '!', [not_author_group.id.to_s])
+ assert_equal 3, query.issues.count
+ assert_query_result issues, query
+ end
+
+ def test_author_role_filter_should_return_issues_with_or_without_author_in_role
+ project = Project.generate!
+ author = User.generate!
+ manager_role = Role.find_by_name('Manager')
+ developer_role = Role.find_by_name('Developer')
+ User.add_to_project(author, project, manager_role)
+ issues = Array.new(3) { Issue.generate!(:project => project, :author => author) }
+
+ query = IssueQuery.new(:name => 'issues generated by manager', :project => project)
+ query.add_filter('author_role', '=', [manager_role.id.to_s])
+ assert_equal 3, query.issues.count
+ assert_query_result issues, query
+
+ query = IssueQuery.new(:name => 'issues does not generated by developer', :project => project)
+ query.add_filter('author_role', '!', [developer_role.id.to_s])
+ assert_equal 3, query.issues.count
+ assert_query_result issues, query
+ end
+
def test_query_column_should_accept_a_symbol_as_caption
set_language_if_valid 'en'
c = QueryColumn.new('foo', :caption => :general_text_Yes)