]> source.dussan.org Git - redmine.git/commitdiff
Fixed: watchers selection lost when issue creation fails (#5406). #watched_by? was...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 30 Apr 2010 11:02:27 +0000 (11:02 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 30 Apr 2010 11:02:27 +0000 (11:02 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3705 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/unit/watcher_test.rb
vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb

index db73f8ccc551236ddca4741f2ed76850ddb23d5e..d0fe588bf1b1d1e8ae63c01c0f3474a8a02fefab 100644 (file)
@@ -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
index f99f4a60d690aa8b064b86861293670e31c84380..b4ac776ece6951dc07d68c3722174aa2498aa916 100644 (file)
@@ -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