]> source.dussan.org Git - redmine.git/commitdiff
Merged r5880 from trunk.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 29 May 2011 07:18:05 +0000 (07:18 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 29 May 2011 07:18:05 +0000 (07:18 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.2-stable@5945 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index d9abb7f6d0a76c1c2820c53b132f63f81ad5e6ee..b9ef579d3cf899846078622be399d6492c1ebb62 100644 (file)
@@ -47,7 +47,28 @@ class WatcherTest < ActiveSupport::TestCase
     assert Issue.watched_by(@user).include?(@issue)
   end
   
+  def test_watcher_users
+    watcher_users = Issue.find(2).watcher_users
+    assert_kind_of Array, watcher_users
+    assert_kind_of User, watcher_users.first
+  end
+  
+  def test_watcher_users_should_not_validate_user
+    User.update_all("firstname = ''", "id=1")
+    @user.reload
+    assert !@user.valid?
+    
+    issue = Issue.new(:project => Project.find(1), :tracker_id => 1, :subject => "test", :author => User.find(2))
+    issue.watcher_users << @user
+    issue.save!
+    assert issue.watched_by?(@user)
+  end
+  
   def test_watcher_user_ids
+    assert_equal [1, 3], Issue.find(2).watcher_user_ids.sort
+  end
+  
+  def test_watcher_user_ids=
     issue = Issue.new
     issue.watcher_user_ids = ['1', '3']
     assert issue.watched_by?(User.find(1))
index a22098eec587f9cb6372b55afd3dba7543023d6f..e9c0eb3e6eb5d4c92115e8fcd62bd2aff591c2dc 100644 (file)
@@ -13,7 +13,7 @@ module Redmine
           
           class_eval do
             has_many :watchers, :as => :watchable, :dependent => :delete_all
-            has_many :watcher_users, :through => :watchers, :source => :user
+            has_many :watcher_users, :through => :watchers, :source => :user, :validate => false
             
             named_scope :watched_by, lambda { |user_id|
               { :include => :watchers,