##// END OF EJS Templates
Merged r15609 (#23278)....
Jean-Philippe Lang -
r15255:f2317792524b
parent child
Show More
@@ -40,12 +40,16 module Redmine
40 40
41 41 # Adds user as a watcher
42 42 def add_watcher(user)
43 # Rails does not reset the has_many :through association
44 watcher_users.reset
43 45 self.watchers << Watcher.new(:user => user)
44 46 end
45 47
46 48 # Removes user from the watchers list
47 49 def remove_watcher(user)
48 50 return nil unless user && user.is_a?(User)
51 # Rails does not reset the has_many :through association
52 watcher_users.reset
49 53 watchers.where(:user_id => user.id).delete_all
50 54 end
51 55
@@ -277,12 +277,13 class MailHandlerTest < ActiveSupport::TestCase
277 277 end
278 278
279 279 def test_add_issue_should_add_cc_as_watchers
280 user = User.find_by_mail('dlopper@somenet.foo')
280 281 issue = submit_email('ticket_with_cc.eml', :issue => {:project => 'ecookbook'})
281 282 assert issue.is_a?(Issue)
282 283 assert !issue.new_record?
283 issue.reload
284 assert issue.watched_by?(User.find_by_mail('dlopper@somenet.foo'))
284 assert issue.watched_by?(user)
285 285 assert_equal 1, issue.watcher_user_ids.size
286 assert_include user, issue.watcher_users.to_a
286 287 end
287 288
288 289 def test_add_issue_from_additional_email_address
@@ -60,6 +60,15 class WatcherTest < ActiveSupport::TestCase
60 60 assert_kind_of User, watcher_users.first
61 61 end
62 62
63 def test_watcher_users_should_be_reloaded_after_adding_a_watcher
64 issue = Issue.find(2)
65 user = User.generate!
66
67 assert_difference 'issue.watcher_users.to_a.size' do
68 issue.add_watcher user
69 end
70 end
71
63 72 def test_watcher_users_should_not_validate_user
64 73 User.where(:id => 1).update_all("firstname = ''")
65 74 @user.reload
General Comments 0
You need to be logged in to leave comments. Login now