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
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'}
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