Merged r15609 (#23278).

git-svn-id: http://svn.redmine.org/redmine/branches/3.2-stable@15638 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2016-07-11 18:10:01 +00:00
parent e35c8f7e2e
commit 891736ef39
3 changed files with 16 additions and 2 deletions

View File

@@ -40,12 +40,16 @@ module Redmine
# Adds user as a watcher
def add_watcher(user)
# Rails does not reset the has_many :through association
watcher_users.reset
self.watchers << Watcher.new(:user => user)
end
# Removes user from the watchers list
def remove_watcher(user)
return nil unless user && user.is_a?(User)
# Rails does not reset the has_many :through association
watcher_users.reset
watchers.where(:user_id => user.id).delete_all
end