##// END OF EJS Templates
Merged r15609 (#23278)....
Jean-Philippe Lang -
r15256:891736ef391b
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
@@ -266,12 +266,13 class MailHandlerTest < ActiveSupport::TestCase
266 266 end
267 267
268 268 def test_add_issue_with_cc
269 user = User.find_by_mail('dlopper@somenet.foo')
269 270 issue = submit_email('ticket_with_cc.eml', :issue => {:project => 'ecookbook'})
270 271 assert issue.is_a?(Issue)
271 272 assert !issue.new_record?
272 issue.reload
273 assert issue.watched_by?(User.find_by_mail('dlopper@somenet.foo'))
273 assert issue.watched_by?(user)
274 274 assert_equal 1, issue.watcher_user_ids.size
275 assert_include user, issue.watcher_users.to_a
275 276 end
276 277
277 278 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