assert issue.watched_by?(User.find(1))
end
+ def test_addable_watcher_users
+ addable_watcher_users = @issue.addable_watcher_users
+ assert_kind_of Array, addable_watcher_users
+ assert_kind_of User, addable_watcher_users.first
+ end
+
+ def test_addable_watcher_users_should_not_include_user_that_cannot_view_the_object
+ issue = Issue.new(:project => Project.find(1), :is_private => true)
+ assert_nil issue.addable_watcher_users.detect {|user| !issue.visible?(user)}
+ end
+
def test_recipients
@issue.watchers.delete_all
@issue.reload
# Returns an array of users that are proposed as watchers
def addable_watcher_users
- self.project.users.sort - self.watcher_users
+ users = self.project.users.sort - self.watcher_users
+ if respond_to?(:visible?)
+ users.reject! {|user| !visible?(user)}
+ end
+ users
end
# Adds user as a watcher