diff --git a/test/unit/watcher_test.rb b/test/unit/watcher_test.rb index db73f8ccc..d0fe588bf 100644 --- a/test/unit/watcher_test.rb +++ b/test/unit/watcher_test.rb @@ -47,6 +47,12 @@ class WatcherTest < ActiveSupport::TestCase assert Issue.watched_by(@user).include?(@issue) end + def test_watcher_user_ids + issue = Issue.new + issue.watcher_user_ids = ['1', '3'] + assert issue.watched_by?(User.find(1)) + end + def test_recipients @issue.watchers.delete_all @issue.reload diff --git a/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb b/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb index f99f4a60d..b4ac776ec 100644 --- a/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb +++ b/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb @@ -50,9 +50,9 @@ module Redmine watching ? add_watcher(user) : remove_watcher(user) end - # Returns true if object is watched by user + # Returns true if object is watched by +user+ def watched_by?(user) - !!(user && self.watchers.detect {|w| w.user_id == user.id }) + !!(user && self.watcher_user_ids.detect {|uid| uid == user.id }) end # Returns an array of watchers' email addresses