##// END OF EJS Templates
Do not propose users that can't view an issue as watchers (#7412)....
Jean-Philippe Lang -
r5756:7e1f04bdfb6f
parent child
Show More
@@ -53,6 +53,17 class WatcherTest < ActiveSupport::TestCase
53 53 assert issue.watched_by?(User.find(1))
54 54 end
55 55
56 def test_addable_watcher_users
57 addable_watcher_users = @issue.addable_watcher_users
58 assert_kind_of Array, addable_watcher_users
59 assert_kind_of User, addable_watcher_users.first
60 end
61
62 def test_addable_watcher_users_should_not_include_user_that_cannot_view_the_object
63 issue = Issue.new(:project => Project.find(1), :is_private => true)
64 assert_nil issue.addable_watcher_users.detect {|user| !issue.visible?(user)}
65 end
66
56 67 def test_recipients
57 68 @issue.watchers.delete_all
58 69 @issue.reload
@@ -31,7 +31,11 module Redmine
31 31
32 32 # Returns an array of users that are proposed as watchers
33 33 def addable_watcher_users
34 self.project.users.sort - self.watcher_users
34 users = self.project.users.sort - self.watcher_users
35 if respond_to?(:visible?)
36 users.reject! {|user| !visible?(user)}
37 end
38 users
35 39 end
36 40
37 41 # Adds user as a watcher
General Comments 0
You need to be logged in to leave comments. Login now