diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-04-28 09:25:51 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-04-28 09:25:51 +0000 |
commit | e55c1d82e633c692324c9b0289ffeeb15b11e383 (patch) | |
tree | 5afe9984dec472775677c81125ab06776b9ab58a | |
parent | 67e7758185c6344f95eb9d071b869cdcb0ef9ed5 (diff) | |
download | redmine-e55c1d82e633c692324c9b0289ffeeb15b11e383.tar.gz redmine-e55c1d82e633c692324c9b0289ffeeb15b11e383.zip |
Notify project members when a message is posted if they want to receive notifications for everything on the project (#1079).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1368 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/models/message_observer.rb | 2 | ||||
-rw-r--r-- | test/functional/messages_controller_test.rb | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/app/models/message_observer.rb b/app/models/message_observer.rb index c26805c1b..043988172 100644 --- a/app/models/message_observer.rb +++ b/app/models/message_observer.rb @@ -21,6 +21,8 @@ class MessageObserver < ActiveRecord::Observer recipients = ([message.root] + message.root.children).collect {|m| m.author.mail if m.author && m.author.active?} # send notification to the board watchers recipients += message.board.watcher_recipients + # send notification to project members who want to be notified + recipients += message.board.project.recipients recipients = recipients.compact.uniq Mailer.deliver_message_posted(message, recipients) if !recipients.empty? && Setting.notified_events.include?('message_posted') end diff --git a/test/functional/messages_controller_test.rb b/test/functional/messages_controller_test.rb index dcfe0caa7..1fe8d086a 100644 --- a/test/functional/messages_controller_test.rb +++ b/test/functional/messages_controller_test.rb @@ -54,6 +54,9 @@ class MessagesControllerTest < Test::Unit::TestCase def test_post_new @request.session[:user_id] = 2 + ActionMailer::Base.deliveries.clear + Setting.notified_events << 'message_posted' + post :new, :board_id => 1, :message => { :subject => 'Test created message', :content => 'Message body'} @@ -63,6 +66,15 @@ class MessagesControllerTest < Test::Unit::TestCase assert_equal 'Message body', message.content assert_equal 2, message.author_id assert_equal 1, message.board_id + + mail = ActionMailer::Base.deliveries.last + assert_kind_of TMail::Mail, mail + assert_equal "[#{message.board.project.name} - #{message.board.name}] Test created message", mail.subject + assert mail.body.include?('Message body') + # author + assert mail.bcc.include?('jsmith@somenet.foo') + # project member + assert mail.bcc.include?('dlopper@somenet.foo') end def test_get_edit |