summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2024-05-12 07:42:45 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2024-05-12 07:42:45 +0000
commit707e4de168586ec7455e2517447f1658c2d4c88f (patch)
tree0fcc87b29e7fb40a6e8dd0db67c222eb33cbb05a /test
parentf87be7fd540828a39911f6757d82cc76922b428c (diff)
downloadredmine-707e4de168586ec7455e2517447f1658c2d4c88f.tar.gz
redmine-707e4de168586ec7455e2517447f1658c2d4c88f.zip
Merged r22819 and r22820 to 5.0-stable (#40412).
git-svn-id: https://svn.redmine.org/redmine/branches/5.0-stable@22825 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/unit/query_test.rb41
1 files changed, 38 insertions, 3 deletions
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index 6544e08f7..2d5f2fd4c 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -1067,7 +1067,7 @@ class QueryTest < ActiveSupport::TestCase
assert_equal Project.where(parent_id: bookmarks).ids, result.map(&:id).sort
end
- def test_filter_watched_issues
+ def test_filter_watched_issues_by_user
User.current = User.find(1)
query =
IssueQuery.new(
@@ -1075,7 +1075,7 @@ class QueryTest < ActiveSupport::TestCase
:filters => {
'watcher_id' => {
:operator => '=',
- :values => ['me']
+ :values => [User.current.id]
}
}
)
@@ -1085,13 +1085,17 @@ class QueryTest < ActiveSupport::TestCase
assert_equal Issue.visible.watched_by(User.current).sort_by(&:id), result.sort_by(&:id)
end
- def test_filter_watched_issues_with_groups_also
+ def test_filter_watched_issues_by_me_should_include_user_groups
user = User.find(2)
group = Group.find(10)
group.users << user
Issue.find(3).add_watcher(user)
Issue.find(7).add_watcher(group)
+ manager = Role.find(1)
+ # view_issue_watchers permission is not required to see watched issues by current user or user groups
+ manager.remove_permission! :view_issue_watchers
User.current = user
+
query =
IssueQuery.new(
:name => '_',
@@ -1103,11 +1107,42 @@ class QueryTest < ActiveSupport::TestCase
}
)
result = find_issues_with_query(query)
+
assert_not_nil result
assert !result.empty?
assert_equal [3, 7], result.sort_by(&:id).pluck(:id)
end
+ def test_filter_watched_issues_by_group_should_include_only_projects_with_permission
+ user = User.find(2)
+ group = Group.find(10)
+
+ Issue.find(4).add_watcher(group)
+ Issue.find(2).add_watcher(group)
+
+ developer = Role.find(2)
+ developer.remove_permission! :view_issue_watchers
+
+ User.current = user
+
+ query =
+ IssueQuery.new(
+ :name => '_',
+ :filters => {
+ 'watcher_id' => {
+ :operator => '=',
+ :values => [group.id]
+ }
+ }
+ )
+ result = find_issues_with_query(query)
+
+ assert_not_nil result
+
+ # "Developer" role doesn't have the view_issue_watchers permission of issue's #4 project (OnlineStore).
+ assert_equal [2], result.pluck(:id)
+ end
+
def test_filter_unwatched_issues
User.current = User.find(1)
query =