Feature #30820 » 0001-Remove-setting-Blind-carbon-copy-recipients-bcc.patch
app/models/mailer.rb | ||
---|---|---|
697 | 697 |
redmine_headers 'Sender' => @author.login |
698 | 698 |
end |
699 | 699 | |
700 |
# Blind carbon copy recipients |
|
701 |
if Setting.bcc_recipients? |
|
702 |
headers[:bcc] = [headers[:to], headers[:cc]].flatten.uniq.reject(&:blank?) |
|
703 |
headers[:to] = nil |
|
704 |
headers[:cc] = nil |
|
705 |
end |
|
706 | ||
707 | 700 |
if @message_id_object |
708 | 701 |
headers[:message_id] = "<#{self.class.message_id_for(@message_id_object, @user)}>" |
709 | 702 |
end |
app/views/settings/_notifications.html.erb | ||
---|---|---|
4 | 4 |
<div class="box tabular settings"> |
5 | 5 |
<p><%= setting_text_field :mail_from, :size => 60 %></p> |
6 | 6 | |
7 |
<p><%= setting_check_box :bcc_recipients %></p> |
|
8 | ||
9 | 7 |
<p><%= setting_check_box :plain_text_mail %></p> |
10 | 8 | |
11 | 9 |
<p><%= setting_check_box :show_status_changes_in_mail_subject %></p> |
config/locales/en.yml | ||
---|---|---|
418 | 418 |
setting_bulk_download_max_size: Maximum total size for bulk download |
419 | 419 |
setting_issues_export_limit: Issues export limit |
420 | 420 |
setting_mail_from: Emission email address |
421 |
setting_bcc_recipients: Blind carbon copy recipients (bcc) |
|
422 | 421 |
setting_plain_text_mail: Plain text mail (no HTML) |
423 | 422 |
setting_host_name: Host name and path |
424 | 423 |
setting_text_formatting: Text formatting |
config/settings.yml | ||
---|---|---|
92 | 92 |
default: 10 |
93 | 93 |
mail_from: |
94 | 94 |
default: redmine@example.net |
95 |
bcc_recipients: |
|
96 |
default: 1 |
|
97 | 95 |
plain_text_mail: |
98 | 96 |
default: 0 |
99 | 97 |
text_formatting: |
db/migrate/20190217164229_remove_bcc_recipients_setting.rb | ||
---|---|---|
1 |
class RemoveBccRecipientsSetting < ActiveRecord::Migration[5.2] |
|
2 |
def change |
|
3 |
Setting.where(:name => 'bcc_recipients').delete_all |
|
4 |
end |
|
5 |
end |
test/functional/account_controller_test.rb | ||
---|---|---|
445 | 445 |
end |
446 | 446 |
end |
447 | 447 |
mail = ActionMailer::Base.deliveries.last |
448 |
assert_equal ['jsmith@somenet.foo'], mail.bcc
|
|
448 |
assert_equal ['jsmith@somenet.foo'], mail.to
|
|
449 | 449 |
end |
450 | 450 | |
451 | 451 |
def test_lost_password_using_additional_email_address_should_send_email_to_the_address |
... | ... | |
463 | 463 |
end |
464 | 464 |
end |
465 | 465 |
mail = ActionMailer::Base.deliveries.last |
466 |
assert_equal ['anotherAddress@foo.bar'], mail.bcc
|
|
466 |
assert_equal ['anotherAddress@foo.bar'], mail.to
|
|
467 | 467 |
end |
468 | 468 | |
469 | 469 |
def test_lost_password_for_unknown_user_should_fail |
test/functional/admin_controller_test.rb | ||
---|---|---|
107 | 107 |
mail = ActionMailer::Base.deliveries.last |
108 | 108 |
assert_not_nil mail |
109 | 109 |
user = User.find(1) |
110 |
assert_equal [user.mail], mail.bcc
|
|
110 |
assert_equal [user.mail], mail.to
|
|
111 | 111 |
end |
112 | 112 | |
113 | 113 |
def test_test_email_failure_should_display_the_error |
test/functional/email_addresses_controller_test.rb | ||
---|---|---|
172 | 172 |
assert_select 'a[href^=?]', 'http://localhost:3000/my/account', :text => 'My account' |
173 | 173 |
end |
174 | 174 |
# The old email address should be notified about a new address for security purposes |
175 |
assert [mail.bcc, mail.cc].flatten.include?(User.find(2).mail)
|
|
176 |
assert [mail.bcc, mail.cc].flatten.include?('something@example.fr')
|
|
175 |
assert mail.to.include?(User.find(2).mail)
|
|
176 |
assert mail.to.include?('something@example.fr')
|
|
177 | 177 |
end |
178 | 178 | |
179 | 179 |
def test_update |
... | ... | |
230 | 230 |
assert_mail_body_match I18n.t(:mail_body_security_notification_notify_disabled, value: 'another@somenet.foo'), mail |
231 | 231 | |
232 | 232 |
# The changed address should be notified for security purposes |
233 |
assert [mail.bcc, mail.cc].flatten.include?('another@somenet.foo')
|
|
233 |
assert mail.to.include?('another@somenet.foo')
|
|
234 | 234 |
end |
235 | 235 | |
236 | 236 |
def test_destroy |
... | ... | |
300 | 300 |
assert_mail_body_match I18n.t(:mail_body_security_notification_remove, field: I18n.t(:field_mail), value: 'another@somenet.foo'), mail |
301 | 301 | |
302 | 302 |
# The removed address should be notified for security purposes |
303 |
assert [mail.bcc, mail.cc].flatten.include?('another@somenet.foo')
|
|
303 |
assert mail.to.include?('another@somenet.foo')
|
|
304 | 304 |
end |
305 | 305 |
end |
test/functional/issues_controller_test.rb | ||
---|---|---|
4323 | 4323 |
# Watchers notified |
4324 | 4324 |
assert_equal 3, ActionMailer::Base.deliveries.size |
4325 | 4325 |
mail = ActionMailer::Base.deliveries[1] |
4326 |
assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail)
|
|
4326 |
assert [mail.to].flatten.include?(User.find(3).mail)
|
|
4327 | 4327 |
mail = ActionMailer::Base.deliveries[2] |
4328 |
assert [mail.bcc, mail.cc].flatten.include?(User.find(8).mail)
|
|
4328 |
assert [mail.to].flatten.include?(User.find(8).mail)
|
|
4329 | 4329 |
end |
4330 | 4330 | |
4331 | 4331 |
def test_post_create_subissue |
test/functional/issues_custom_fields_visibility_test.rb | ||
---|---|---|
281 | 281 | |
282 | 282 |
ActionMailer::Base.deliveries.clear |
283 | 283 |
@request.session[:user_id] = 1 |
284 |
with_settings :bcc_recipients => '1' do |
|
285 |
assert_difference 'Issue.count' do |
|
286 |
post( |
|
287 |
:create, |
|
288 |
:params => { |
|
289 |
:project_id => 1, |
|
290 |
:issue => { |
|
291 |
:tracker_id => 1, |
|
292 |
:status_id => 1, |
|
293 |
:subject => 'New issue', |
|
294 |
:priority_id => 5, |
|
295 |
:custom_field_values => { |
|
296 |
@field1.id.to_s => 'Value0', |
|
297 |
@field2.id.to_s => 'Value1', |
|
298 |
@field3.id.to_s => 'Value2' |
|
299 |
}, |
|
300 |
:watcher_user_ids => users_to_test.keys.map(&:id) |
|
301 |
} |
|
284 |
assert_difference 'Issue.count' do |
|
285 |
post( |
|
286 |
:create, |
|
287 |
:params => { |
|
288 |
:project_id => 1, |
|
289 |
:issue => { |
|
290 |
:tracker_id => 1, |
|
291 |
:status_id => 1, |
|
292 |
:subject => 'New issue', |
|
293 |
:priority_id => 5, |
|
294 |
:custom_field_values => { |
|
295 |
@field1.id.to_s => 'Value0', |
|
296 |
@field2.id.to_s => 'Value1', |
|
297 |
@field3.id.to_s => 'Value2' |
|
298 |
}, |
|
299 |
:watcher_user_ids => users_to_test.keys.map(&:id) |
|
302 | 300 |
} |
303 |
)
|
|
304 |
assert_response 302
|
|
305 |
end
|
|
301 |
}
|
|
302 |
)
|
|
303 |
assert_response 302
|
|
306 | 304 |
end |
307 | 305 | |
308 | 306 |
assert_equal users_to_test.keys.size, ActionMailer::Base.deliveries.size |
309 | 307 |
# tests that each user receives 1 email with the custom fields he is allowed to see only |
310 | 308 |
users_to_test.each do |user, fields| |
311 |
mails = ActionMailer::Base.deliveries.select {|m| m.bcc.include? user.mail}
|
|
309 |
mails = ActionMailer::Base.deliveries.select {|m| m.to.include? user.mail}
|
|
312 | 310 |
assert_equal 1, mails.size |
313 | 311 |
mail = mails.first |
314 | 312 |
@fields.each_with_index do |field, i| |
... | ... | |
330 | 328 |
end |
331 | 329 |
ActionMailer::Base.deliveries.clear |
332 | 330 |
@request.session[:user_id] = 1 |
333 |
with_settings :bcc_recipients => '1' do |
|
334 |
put( |
|
335 |
:update, |
|
336 |
:params => { |
|
337 |
:id => @issue.id, |
|
338 |
:issue => { |
|
339 |
:custom_field_values => { |
|
340 |
@field1.id.to_s => 'NewValue0', |
|
341 |
@field2.id.to_s => 'NewValue1', |
|
342 |
@field3.id.to_s => 'NewValue2' |
|
343 |
} |
|
331 |
put( |
|
332 |
:update, |
|
333 |
:params => { |
|
334 |
:id => @issue.id, |
|
335 |
:issue => { |
|
336 |
:custom_field_values => { |
|
337 |
@field1.id.to_s => 'NewValue0', |
|
338 |
@field2.id.to_s => 'NewValue1', |
|
339 |
@field3.id.to_s => 'NewValue2' |
|
344 | 340 |
} |
345 | 341 |
} |
346 |
)
|
|
347 |
assert_response 302
|
|
348 |
end
|
|
342 |
}
|
|
343 |
)
|
|
344 |
assert_response 302
|
|
349 | 345 |
assert_equal users_to_test.keys.size, ActionMailer::Base.deliveries.size |
350 | 346 |
# tests that each user receives 1 email with the custom fields he is allowed to see only |
351 | 347 |
users_to_test.each do |user, fields| |
352 |
mails = ActionMailer::Base.deliveries.select {|m| m.bcc.include? user.mail}
|
|
348 |
mails = ActionMailer::Base.deliveries.select {|m| m.to.include? user.mail}
|
|
353 | 349 |
assert_equal 1, mails.size |
354 | 350 |
mail = mails.first |
355 | 351 |
@fields.each_with_index do |field, i| |
... | ... | |
371 | 367 |
end |
372 | 368 |
ActionMailer::Base.deliveries.clear |
373 | 369 |
@request.session[:user_id] = 1 |
374 |
with_settings :bcc_recipients => '1' do |
|
375 |
put( |
|
376 |
:update, |
|
377 |
:params => { |
|
378 |
:id => @issue.id, |
|
379 |
:issue => { |
|
380 |
:custom_field_values => { |
|
381 |
@field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2' |
|
382 |
} |
|
370 |
put( |
|
371 |
:update, |
|
372 |
:params => { |
|
373 |
:id => @issue.id, |
|
374 |
:issue => { |
|
375 |
:custom_field_values => { |
|
376 |
@field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2' |
|
383 | 377 |
} |
384 | 378 |
} |
385 |
)
|
|
386 |
assert_response 302
|
|
387 |
end
|
|
379 |
}
|
|
380 |
)
|
|
381 |
assert_response 302
|
|
388 | 382 |
users_to_test.each do |user, fields| |
389 |
mails = ActionMailer::Base.deliveries.select {|m| m.bcc.include? user.mail}
|
|
383 |
mails = ActionMailer::Base.deliveries.select {|m| m.to.include? user.mail}
|
|
390 | 384 |
if (fields & [@field2, @field3]).any? |
391 | 385 |
assert_equal 1, mails.size, "User #{user.id} was not notified" |
392 | 386 |
else |
test/functional/messages_controller_test.rb | ||
---|---|---|
159 | 159 |
assert_mail_body_match 'Message body', mail |
160 | 160 |
end |
161 | 161 | |
162 |
bcc_email_addresses = mails.map(&:bcc).flatten |
|
163 | 162 |
# author |
164 |
assert_includes bcc_email_addresses, 'jsmith@somenet.foo'
|
|
163 |
assert_equal ['jsmith@somenet.foo'], mails[0].to
|
|
165 | 164 |
# project member |
166 |
assert_includes bcc_email_addresses, 'dlopper@somenet.foo'
|
|
165 |
assert_equal ['dlopper@somenet.foo'], mails[1].to
|
|
167 | 166 |
end |
168 | 167 | |
169 | 168 |
def test_get_edit |
test/functional/my_controller_test.rb | ||
---|---|---|
506 | 506 |
assert_select 'a[href^=?]', 'http://localhost:3000/my/account', :text => 'My account' |
507 | 507 |
end |
508 | 508 |
# The old email address should be notified about the change for security purposes |
509 |
assert [mail.bcc, mail.cc].flatten.include?(User.find(2).mail)
|
|
510 |
assert [mail.bcc, mail.cc].flatten.include?('foobar@example.com')
|
|
509 |
assert mail.to.include?(User.find(2).mail)
|
|
510 |
assert mail.to.include?('foobar@example.com')
|
|
511 | 511 |
end |
512 | 512 | |
513 | 513 |
def test_my_account_notify_about_high_priority_issues_preference |
test/functional/settings_controller_test.rb | ||
---|---|---|
78 | 78 |
post :edit, :params => { |
79 | 79 |
:settings => { |
80 | 80 |
:mail_from => 'functional@test.foo', |
81 |
:bcc_recipients => '0', |
|
82 | 81 |
:notified_events => %w(issue_added issue_updated news_added), |
83 | 82 |
:emails_footer => 'Test footer' |
84 | 83 |
} |
85 | 84 |
} |
86 | 85 |
assert_redirected_to '/settings' |
87 | 86 |
assert_equal 'functional@test.foo', Setting.mail_from |
88 |
assert !Setting.bcc_recipients? |
|
89 | 87 |
assert_equal %w(issue_added issue_updated news_added), Setting.notified_events |
90 | 88 |
assert_equal 'Test footer', Setting.emails_footer |
91 | 89 |
end |
... | ... | |
174 | 172 |
assert_select 'a[href^=?]', 'http://localhost:3000/settings' |
175 | 173 |
end |
176 | 174 |
# All admins should receive this |
177 |
recipients = [mail.bcc, mail.cc].flatten |
|
178 | 175 |
User.active.where(admin: true).each do |admin| |
179 |
assert_include admin.mail, recipients
|
|
176 |
assert_include admin.mail, mail.to
|
|
180 | 177 |
end |
181 | 178 |
end |
182 | 179 |
test/functional/users_controller_test.rb | ||
---|---|---|
283 | 283 |
end |
284 | 284 | |
285 | 285 |
def test_create |
286 |
with_settings :bcc_recipients => '1' do |
|
287 |
assert_difference 'User.count' do |
|
288 |
assert_difference 'ActionMailer::Base.deliveries.size' do |
|
289 |
post( |
|
290 |
:create, |
|
291 |
:params => { |
|
292 |
:user => { |
|
293 |
:firstname => 'John', |
|
294 |
:lastname => 'Doe', |
|
295 |
:login => 'jdoe', |
|
296 |
:password => 'secret123', |
|
297 |
:password_confirmation => 'secret123', |
|
298 |
:mail => 'jdoe@gmail.com', |
|
299 |
:mail_notification => 'none' |
|
300 |
}, |
|
301 |
:send_information => '1' |
|
302 |
} |
|
303 |
) |
|
304 |
end |
|
286 |
assert_difference 'User.count' do |
|
287 |
assert_difference 'ActionMailer::Base.deliveries.size' do |
|
288 |
post :create, :params => { |
|
289 |
:user => { |
|
290 |
:firstname => 'John', |
|
291 |
:lastname => 'Doe', |
|
292 |
:login => 'jdoe', |
|
293 |
:password => 'secret123', |
|
294 |
:password_confirmation => 'secret123', |
|
295 |
:mail => 'jdoe@gmail.com', |
|
296 |
:mail_notification => 'none' |
|
297 |
}, |
|
298 |
:send_information => '1' |
|
299 |
} |
|
305 | 300 |
end |
306 | 301 |
end |
307 | 302 | |
... | ... | |
317 | 312 | |
318 | 313 |
mail = ActionMailer::Base.deliveries.last |
319 | 314 |
assert_not_nil mail |
320 |
assert_equal [user.mail], mail.bcc
|
|
315 |
assert_equal [user.mail], mail.to
|
|
321 | 316 |
assert_mail_body_match 'secret', mail |
322 | 317 |
end |
323 | 318 | |
... | ... | |
455 | 450 |
User.where(admin: true, status: Principal::STATUS_ACTIVE).each do |admin| |
456 | 451 |
assert_not_nil( |
457 | 452 |
ActionMailer::Base.deliveries.detect do |mail| |
458 |
[mail.bcc, mail.cc].flatten.include?(admin.mail)
|
|
453 |
[mail.to].flatten.include?(admin.mail)
|
|
459 | 454 |
end |
460 | 455 |
) |
461 | 456 |
end |
... | ... | |
550 | 545 |
u.status = User::STATUS_REGISTERED |
551 | 546 |
u.save! |
552 | 547 |
ActionMailer::Base.deliveries.clear |
553 |
with_settings :bcc_recipients => '1' do |
|
554 |
put( |
|
555 |
:update, |
|
556 |
:params => { |
|
557 |
:id => u.id, |
|
558 |
:user => {:status => User::STATUS_ACTIVE} |
|
559 |
} |
|
560 |
) |
|
561 |
end |
|
548 | ||
549 |
put :update, :params => { |
|
550 |
:id => u.id, |
|
551 |
:user => {:status => User::STATUS_ACTIVE} |
|
552 |
} |
|
553 | ||
562 | 554 |
assert u.reload.active? |
563 | 555 |
mail = ActionMailer::Base.deliveries.last |
564 | 556 |
assert_not_nil mail |
565 |
assert_equal ['foo.bar@somenet.foo'], mail.bcc
|
|
557 |
assert_equal ['foo.bar@somenet.foo'], mail.to
|
|
566 | 558 |
assert_mail_body_match ll('fr', :notice_account_activated), mail |
567 | 559 |
end |
568 | 560 | |
569 | 561 |
def test_update_with_password_change_should_send_a_notification |
570 | 562 |
ActionMailer::Base.deliveries.clear |
571 |
with_settings :bcc_recipients => '1' do |
|
572 |
put( |
|
573 |
:update, |
|
574 |
:params => { |
|
575 |
:id => 2, |
|
576 |
:user => { |
|
577 |
:password => 'newpass123', |
|
578 |
:password_confirmation => 'newpass123' |
|
579 |
}, |
|
580 |
:send_information => '1' |
|
581 |
} |
|
582 |
) |
|
583 |
end |
|
563 |
put :update, :params => { |
|
564 |
:id => 2, |
|
565 |
:user => {:password => 'newpass123', :password_confirmation => 'newpass123'}, |
|
566 |
:send_information => '1' |
|
567 |
} |
|
568 | ||
584 | 569 |
u = User.find(2) |
585 | 570 |
assert u.check_password?('newpass123') |
586 | 571 | |
587 | 572 |
mail = ActionMailer::Base.deliveries.last |
588 | 573 |
assert_not_nil mail |
589 |
assert_equal [u.mail], mail.bcc
|
|
574 |
assert_equal [u.mail], mail.to
|
|
590 | 575 |
assert_mail_body_match 'newpass123', mail |
591 | 576 |
end |
592 | 577 | |
593 | 578 |
def test_update_with_generate_password_should_email_the_password |
594 | 579 |
ActionMailer::Base.deliveries.clear |
595 |
with_settings :bcc_recipients => '1' do |
|
596 |
put( |
|
597 |
:update, |
|
598 |
:params => { |
|
599 |
:id => 2, |
|
600 |
:user => { |
|
601 |
:generate_password => '1', |
|
602 |
:password => '', |
|
603 |
:password_confirmation => '' |
|
604 |
}, |
|
605 |
:send_information => '1' |
|
606 |
} |
|
607 |
) |
|
608 |
end |
|
580 | ||
581 |
put :update, :params => { |
|
582 |
:id => 2, |
|
583 |
:user => { |
|
584 |
:generate_password => '1', |
|
585 |
:password => '', |
|
586 |
:password_confirmation => '' |
|
587 |
}, |
|
588 |
:send_information => '1' |
|
589 |
} |
|
590 | ||
609 | 591 |
mail = ActionMailer::Base.deliveries.last |
610 | 592 |
assert_not_nil mail |
611 | 593 |
u = User.find(2) |
612 |
assert_equal [u.mail], mail.bcc
|
|
594 |
assert_equal [u.mail], mail.to
|
|
613 | 595 |
m = mail_body(mail).match(/Password: ([a-zA-Z0-9]+)/) |
614 | 596 |
assert m |
615 | 597 |
password = m[1] |
... | ... | |
702 | 684 |
User.where(admin: true, status: Principal::STATUS_ACTIVE).each do |admin| |
703 | 685 |
assert_not_nil( |
704 | 686 |
ActionMailer::Base.deliveries.detect do |mail| |
705 |
[mail.bcc, mail.cc].flatten.include?(admin.mail)
|
|
687 |
[mail.to].flatten.include?(admin.mail)
|
|
706 | 688 |
end |
707 | 689 |
) |
708 | 690 |
end |
... | ... | |
732 | 714 |
User.where(admin: true, status: Principal::STATUS_ACTIVE).each do |admin| |
733 | 715 |
assert_not_nil( |
734 | 716 |
ActionMailer::Base.deliveries.detect do |mail| |
735 |
[mail.bcc, mail.cc].flatten.include?(admin.mail)
|
|
717 |
[mail.to].flatten.include?(admin.mail)
|
|
736 | 718 |
end |
737 | 719 |
) |
738 | 720 |
end |
... | ... | |
762 | 744 |
User.where(admin: true, status: Principal::STATUS_ACTIVE).each do |admin| |
763 | 745 |
assert_not_nil( |
764 | 746 |
ActionMailer::Base.deliveries.detect do |mail| |
765 |
[mail.bcc, mail.cc].flatten.include?(admin.mail)
|
|
747 |
[mail.to].flatten.include?(admin.mail)
|
|
766 | 748 |
end |
767 | 749 |
) |
768 | 750 |
end |
... | ... | |
798 | 780 |
User.where(admin: true, status: Principal::STATUS_ACTIVE).each do |admin| |
799 | 781 |
assert_not_nil( |
800 | 782 |
ActionMailer::Base.deliveries.detect do |mail| |
801 |
[mail.bcc, mail.cc].flatten.include?(admin.mail)
|
|
783 |
[mail.to].flatten.include?(admin.mail)
|
|
802 | 784 |
end |
803 | 785 |
) |
804 | 786 |
end |
... | ... | |
910 | 892 |
User.where(admin: true, status: Principal::STATUS_ACTIVE).each do |admin| |
911 | 893 |
assert_not_nil( |
912 | 894 |
ActionMailer::Base.deliveries.detect do |mail| |
913 |
[mail.bcc, mail.cc].flatten.include?(admin.mail)
|
|
895 |
[mail.to].flatten.include?(admin.mail)
|
|
914 | 896 |
end |
915 | 897 |
) |
916 | 898 |
end |
test/unit/issue_test.rb | ||
---|---|---|
2686 | 2686 |
issue.assigned_to = nil |
2687 | 2687 |
issue.save! |
2688 | 2688 | |
2689 |
assert_include [user.mail], ActionMailer::Base.deliveries.map(&:bcc)
|
|
2689 |
assert_include [user.mail], ActionMailer::Base.deliveries.map(&:to)
|
|
2690 | 2690 |
end |
2691 | 2691 |
end |
2692 | 2692 |
test/unit/mailer_test.rb | ||
---|---|---|
297 | 297 |
user.pref.save |
298 | 298 |
User.current = user |
299 | 299 |
Mailer.deliver_news_added(news.reload) |
300 |
assert_equal 1, last_email.bcc.size
|
|
300 |
assert_equal 1, last_email.to.size
|
|
301 | 301 | |
302 | 302 |
# nobody to notify |
303 | 303 |
user.pref.no_self_notified = true |
... | ... | |
404 | 404 |
issue = Issue.find(1) |
405 | 405 |
assert Mailer.deliver_issue_add(issue) |
406 | 406 | |
407 |
assert mail = ActionMailer::Base.deliveries.find {|m| m.bcc.include?('dlopper@somenet.foo')}
|
|
408 |
assert mail.bcc.include?('otheremail@somenet.foo')
|
|
407 |
assert mail = ActionMailer::Base.deliveries.find {|m| m.to.include?('dlopper@somenet.foo')}
|
|
408 |
assert mail.to.include?('otheremail@somenet.foo')
|
|
409 | 409 |
end |
410 | 410 | |
411 | 411 |
test "#issue_add should not notify project members that are not allow to view the issue" do |
... | ... | |
624 | 624 |
def test_version_file_added |
625 | 625 |
attachements = [Attachment.find_by_container_type('Version')] |
626 | 626 |
assert Mailer.deliver_attachments_added(attachements) |
627 |
assert_not_nil last_email.bcc
|
|
628 |
assert last_email.bcc.any?
|
|
627 |
assert_not_nil last_email.to
|
|
628 |
assert last_email.to.any?
|
|
629 | 629 |
assert_select_email do |
630 | 630 |
assert_select "a[href=?]", "http://localhost:3000/projects/ecookbook/files" |
631 | 631 |
end |
... | ... | |
634 | 634 |
def test_project_file_added |
635 | 635 |
attachements = [Attachment.find_by_container_type('Project')] |
636 | 636 |
assert Mailer.deliver_attachments_added(attachements) |
637 |
assert_not_nil last_email.bcc
|
|
638 |
assert last_email.bcc.any?
|
|
637 |
assert_not_nil last_email.to
|
|
638 |
assert last_email.to.any?
|
|
639 | 639 |
assert_select_email do |
640 | 640 |
assert_select "a[href=?]", "http://localhost:3000/projects/ecookbook/files" |
641 | 641 |
end |
... | ... | |
709 | 709 |
Mailer.reminders(:days => days) |
710 | 710 |
assert_equal 1, ActionMailer::Base.deliveries.size |
711 | 711 |
mail = last_email |
712 |
assert mail.bcc.include?('dlopper@somenet.foo')
|
|
712 |
assert mail.to.include?('dlopper@somenet.foo')
|
|
713 | 713 |
assert_mail_body_match 'Bug #3: Error 281 when updating a recipe (5 days late)', mail |
714 | 714 |
assert_mail_body_match 'View all issues (2 open)', mail |
715 | 715 |
url = |
... | ... | |
737 | 737 |
Mailer.reminders(:days => 42) |
738 | 738 |
assert_equal 1, ActionMailer::Base.deliveries.size |
739 | 739 |
mail = last_email |
740 |
assert mail.bcc.include?('dlopper@somenet.foo')
|
|
740 |
assert mail.to.include?('dlopper@somenet.foo')
|
|
741 | 741 |
assert_mail_body_match( |
742 | 742 |
'Bug #3: Error 281 when updating a recipe (En retard de 5 jours)', |
743 | 743 |
|
... | ... | |
757 | 757 |
Mailer.reminders(:days => 42) |
758 | 758 |
assert_equal 1, ActionMailer::Base.deliveries.size |
759 | 759 |
mail = last_email |
760 |
assert mail.bcc.include?('dlopper@somenet.foo')
|
|
760 |
assert mail.to.include?('dlopper@somenet.foo')
|
|
761 | 761 |
assert_mail_body_no_match 'Closed issue', mail |
762 | 762 |
end |
763 | 763 |
end |
... | ... | |
769 | 769 |
Mailer.reminders(:days => 42, :users => ['3']) |
770 | 770 |
assert_equal 1, ActionMailer::Base.deliveries.size # No mail for dlopper |
771 | 771 |
mail = last_email |
772 |
assert mail.bcc.include?('dlopper@somenet.foo')
|
|
772 |
assert mail.to.include?('dlopper@somenet.foo')
|
|
773 | 773 |
assert_mail_body_match 'Bug #3: Error 281 when updating a recipe (5 days late)', mail |
774 | 774 |
end |
775 | 775 | |
... | ... | |
802 | 802 |
) |
803 | 803 |
assert_mail_body_match 'Assigned to group (Due in 5 days)', mail |
804 | 804 |
assert_mail_body_match( |
805 |
"View all issues (#{mail.bcc.include?('dlopper@somenet.foo') ? 3 : 2} open)",
|
|
805 |
"View all issues (#{mail.to.include?('dlopper@somenet.foo') ? 3 : 2} open)",
|
|
806 | 806 |
|
807 | 807 |
) |
808 | 808 |
end |
... | ... | |
1099 | 1099 | |
1100 | 1100 |
# Returns an array of email addresses to which emails were sent |
1101 | 1101 |
def recipients |
1102 |
ActionMailer::Base.deliveries.map(&:bcc).flatten.sort
|
|
1102 |
ActionMailer::Base.deliveries.map(&:to).flatten.sort
|
|
1103 | 1103 |
end |
1104 | 1104 | |
1105 | 1105 |
def last_email |
... | ... | |
1117 | 1117 |
end |
1118 | 1118 | |
1119 | 1119 |
def destination_user(mail) |
1120 |
EmailAddress.where(:address => [mail.to, mail.cc, mail.bcc].flatten).map(&:user).first
|
|
1120 |
EmailAddress.where(:address => [mail.to, mail.cc].flatten).map(&:user).first |
|
1121 | 1121 |
end |
1122 | 1122 |
end |
- « Previous
- 1
- 2
- Next »