]> source.dussan.org Git - redmine.git/commitdiff
Allow to use watch_by filter in the global issues list (#34700).
authorGo MAEDA <maeda@farend.jp>
Thu, 11 Feb 2021 06:48:29 +0000 (06:48 +0000)
committerGo MAEDA <maeda@farend.jp>
Thu, 11 Feb 2021 06:48:29 +0000 (06:48 +0000)
Patch by Holger Just.

git-svn-id: http://svn.redmine.org/redmine/trunk@20744 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/query.rb
test/functional/queries_controller_test.rb

index 039e38e325adfeb558ac2f48693c033c47a323a2..f81f5782a82abed884610bda9fe29cfa24c1beb8 100644 (file)
@@ -615,7 +615,7 @@ class Query < ActiveRecord::Base
 
   def watcher_values
     watcher_values = [["<< #{l(:label_me)} >>", "me"]]
-    if User.current.allowed_to?(:view_issue_watchers, self.project)
+    if User.current.allowed_to?(:view_issue_watchers, self.project, global: true)
       watcher_values +=
         principals.sort_by(&:status).
           collect{|s| [s.name, s.id.to_s, l("status_#{User::LABEL_BY_STATUS[s.status]}")]}
index f0a27f32bd19e42fc1d9549d6d32ced911cd8918..a190aac393d34d16522e340fb8ea2353a217664d 100644 (file)
@@ -895,4 +895,26 @@ class QueriesControllerTest < Redmine::ControllerTest
     assert_include ["Dave2 Lopper2", "5", "locked"], json
     assert_include ["A Team", "10", "active"], json
   end
+
+  def test_watcher_filter_with_permission_should_show_members_and_groups_globally
+    # This user has view_issue_watchers permission
+    @request.session[:user_id] = 1
+    get(
+      :filter,
+      :params => {
+        :type => 'IssueQuery',
+        :name => 'watcher_id'
+      }
+    )
+    assert_response :success
+    assert_equal 'application/json', response.media_type
+    json = ActiveSupport::JSON.decode(response.body)
+
+    assert_equal 8, json.count
+    # "me" value should not be grouped
+    assert_include ['<< me >>', 'me'], json
+    assert_include ['Dave Lopper', '3', 'active'], json
+    assert_include ['Dave2 Lopper2', '5', 'locked'], json
+    assert_include ['A Team', '10', 'active'], json
+  end
 end