@@ -21,6 +21,8 class MessageObserver < ActiveRecord::Observer | |||||
21 | recipients = ([message.root] + message.root.children).collect {|m| m.author.mail if m.author && m.author.active?} |
|
21 | recipients = ([message.root] + message.root.children).collect {|m| m.author.mail if m.author && m.author.active?} | |
22 | # send notification to the board watchers |
|
22 | # send notification to the board watchers | |
23 | recipients += message.board.watcher_recipients |
|
23 | recipients += message.board.watcher_recipients | |
|
24 | # send notification to project members who want to be notified | |||
|
25 | recipients += message.board.project.recipients | |||
24 | recipients = recipients.compact.uniq |
|
26 | recipients = recipients.compact.uniq | |
25 | Mailer.deliver_message_posted(message, recipients) if !recipients.empty? && Setting.notified_events.include?('message_posted') |
|
27 | Mailer.deliver_message_posted(message, recipients) if !recipients.empty? && Setting.notified_events.include?('message_posted') | |
26 | end |
|
28 | end |
@@ -54,6 +54,9 class MessagesControllerTest < Test::Unit::TestCase | |||||
54 |
|
54 | |||
55 | def test_post_new |
|
55 | def test_post_new | |
56 | @request.session[:user_id] = 2 |
|
56 | @request.session[:user_id] = 2 | |
|
57 | ActionMailer::Base.deliveries.clear | |||
|
58 | Setting.notified_events << 'message_posted' | |||
|
59 | ||||
57 | post :new, :board_id => 1, |
|
60 | post :new, :board_id => 1, | |
58 | :message => { :subject => 'Test created message', |
|
61 | :message => { :subject => 'Test created message', | |
59 | :content => 'Message body'} |
|
62 | :content => 'Message body'} | |
@@ -63,6 +66,15 class MessagesControllerTest < Test::Unit::TestCase | |||||
63 | assert_equal 'Message body', message.content |
|
66 | assert_equal 'Message body', message.content | |
64 | assert_equal 2, message.author_id |
|
67 | assert_equal 2, message.author_id | |
65 | assert_equal 1, message.board_id |
|
68 | assert_equal 1, message.board_id | |
|
69 | ||||
|
70 | mail = ActionMailer::Base.deliveries.last | |||
|
71 | assert_kind_of TMail::Mail, mail | |||
|
72 | assert_equal "[#{message.board.project.name} - #{message.board.name}] Test created message", mail.subject | |||
|
73 | assert mail.body.include?('Message body') | |||
|
74 | # author | |||
|
75 | assert mail.bcc.include?('jsmith@somenet.foo') | |||
|
76 | # project member | |||
|
77 | assert mail.bcc.include?('dlopper@somenet.foo') | |||
66 | end |
|
78 | end | |
67 |
|
79 | |||
68 | def test_get_edit |
|
80 | def test_get_edit |
General Comments 0
You need to be logged in to leave comments.
Login now