Remove unused setting 'Blind carbon copy recipients (bcc)' (#30820).

git-svn-id: http://svn.redmine.org/redmine/trunk@21130 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Marius Balteanu
2021-08-01 17:25:13 +00:00
parent c6933b6203
commit 805b36cbfb
16 changed files with 157 additions and 173 deletions

View File

@@ -697,13 +697,6 @@ class Mailer < ActionMailer::Base
redmine_headers 'Sender' => @author.login redmine_headers 'Sender' => @author.login
end end
# Blind carbon copy recipients
if Setting.bcc_recipients?
headers[:bcc] = [headers[:to], headers[:cc]].flatten.uniq.reject(&:blank?)
headers[:to] = nil
headers[:cc] = nil
end
if @message_id_object if @message_id_object
headers[:message_id] = "<#{self.class.message_id_for(@message_id_object, @user)}>" headers[:message_id] = "<#{self.class.message_id_for(@message_id_object, @user)}>"
end end

View File

@@ -4,8 +4,6 @@
<div class="box tabular settings"> <div class="box tabular settings">
<p><%= setting_text_field :mail_from, :size => 60 %></p> <p><%= setting_text_field :mail_from, :size => 60 %></p>
<p><%= setting_check_box :bcc_recipients %></p>
<p><%= setting_check_box :plain_text_mail %></p> <p><%= setting_check_box :plain_text_mail %></p>
<p><%= setting_check_box :show_status_changes_in_mail_subject %></p> <p><%= setting_check_box :show_status_changes_in_mail_subject %></p>

View File

@@ -421,7 +421,6 @@ en:
setting_bulk_download_max_size: Maximum total size for bulk download setting_bulk_download_max_size: Maximum total size for bulk download
setting_issues_export_limit: Issues export limit setting_issues_export_limit: Issues export limit
setting_mail_from: Emission email address setting_mail_from: Emission email address
setting_bcc_recipients: Blind carbon copy recipients (bcc)
setting_plain_text_mail: Plain text mail (no HTML) setting_plain_text_mail: Plain text mail (no HTML)
setting_host_name: Host name and path setting_host_name: Host name and path
setting_text_formatting: Text formatting setting_text_formatting: Text formatting

View File

@@ -92,8 +92,6 @@ search_results_per_page:
default: 10 default: 10
mail_from: mail_from:
default: redmine@example.net default: redmine@example.net
bcc_recipients:
default: 1
plain_text_mail: plain_text_mail:
default: 0 default: 0
text_formatting: text_formatting:

View File

@@ -0,0 +1,5 @@
class RemoveBccRecipientsSetting < ActiveRecord::Migration[6.1]
def change
Setting.where(:name => 'bcc_recipients').delete_all
end
end

View File

@@ -445,7 +445,7 @@ class AccountControllerTest < Redmine::ControllerTest
end end
end end
mail = ActionMailer::Base.deliveries.last mail = ActionMailer::Base.deliveries.last
assert_equal ['jsmith@somenet.foo'], mail.bcc assert_equal ['jsmith@somenet.foo'], mail.to
end end
def test_lost_password_using_additional_email_address_should_send_email_to_the_address def test_lost_password_using_additional_email_address_should_send_email_to_the_address
@@ -463,7 +463,7 @@ class AccountControllerTest < Redmine::ControllerTest
end end
end end
mail = ActionMailer::Base.deliveries.last mail = ActionMailer::Base.deliveries.last
assert_equal ['anotherAddress@foo.bar'], mail.bcc assert_equal ['anotherAddress@foo.bar'], mail.to
end end
def test_lost_password_for_unknown_user_should_fail def test_lost_password_for_unknown_user_should_fail

View File

@@ -107,7 +107,7 @@ class AdminControllerTest < Redmine::ControllerTest
mail = ActionMailer::Base.deliveries.last mail = ActionMailer::Base.deliveries.last
assert_not_nil mail assert_not_nil mail
user = User.find(1) user = User.find(1)
assert_equal [user.mail], mail.bcc assert_equal [user.mail], mail.to
end end
def test_test_email_failure_should_display_the_error def test_test_email_failure_should_display_the_error

View File

@@ -172,8 +172,8 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
assert_select 'a[href^=?]', 'http://localhost:3000/my/account', :text => 'My account' assert_select 'a[href^=?]', 'http://localhost:3000/my/account', :text => 'My account'
end end
# The old email address should be notified about a new address for security purposes # The old email address should be notified about a new address for security purposes
assert [mail.bcc, mail.cc].flatten.include?(User.find(2).mail) assert mail.to.include?(User.find(2).mail)
assert [mail.bcc, mail.cc].flatten.include?('something@example.fr') assert mail.to.include?('something@example.fr')
end end
def test_update def test_update
@@ -230,7 +230,7 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
assert_mail_body_match I18n.t(:mail_body_security_notification_notify_disabled, value: 'another@somenet.foo'), mail assert_mail_body_match I18n.t(:mail_body_security_notification_notify_disabled, value: 'another@somenet.foo'), mail
# The changed address should be notified for security purposes # The changed address should be notified for security purposes
assert [mail.bcc, mail.cc].flatten.include?('another@somenet.foo') assert mail.to.include?('another@somenet.foo')
end end
def test_destroy def test_destroy
@@ -300,6 +300,6 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
assert_mail_body_match I18n.t(:mail_body_security_notification_remove, field: I18n.t(:field_mail), value: 'another@somenet.foo'), mail assert_mail_body_match I18n.t(:mail_body_security_notification_remove, field: I18n.t(:field_mail), value: 'another@somenet.foo'), mail
# The removed address should be notified for security purposes # The removed address should be notified for security purposes
assert [mail.bcc, mail.cc].flatten.include?('another@somenet.foo') assert mail.to.include?('another@somenet.foo')
end end
end end

View File

@@ -4332,9 +4332,9 @@ class IssuesControllerTest < Redmine::ControllerTest
# Watchers notified # Watchers notified
assert_equal 3, ActionMailer::Base.deliveries.size assert_equal 3, ActionMailer::Base.deliveries.size
mail = ActionMailer::Base.deliveries[1] mail = ActionMailer::Base.deliveries[1]
assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail) assert [mail.to].flatten.include?(User.find(3).mail)
mail = ActionMailer::Base.deliveries[2] mail = ActionMailer::Base.deliveries[2]
assert [mail.bcc, mail.cc].flatten.include?(User.find(8).mail) assert [mail.to].flatten.include?(User.find(8).mail)
end end
def test_post_create_subissue def test_post_create_subissue

View File

@@ -281,34 +281,32 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
@request.session[:user_id] = 1 @request.session[:user_id] = 1
with_settings :bcc_recipients => '1' do assert_difference 'Issue.count' do
assert_difference 'Issue.count' do post(
post( :create,
:create, :params => {
:params => { :project_id => 1,
:project_id => 1, :issue => {
:issue => { :tracker_id => 1,
:tracker_id => 1, :status_id => 1,
:status_id => 1, :subject => 'New issue',
:subject => 'New issue', :priority_id => 5,
:priority_id => 5, :custom_field_values => {
:custom_field_values => { @field1.id.to_s => 'Value0',
@field1.id.to_s => 'Value0', @field2.id.to_s => 'Value1',
@field2.id.to_s => 'Value1', @field3.id.to_s => 'Value2'
@field3.id.to_s => 'Value2' },
}, :watcher_user_ids => users_to_test.keys.map(&:id)
:watcher_user_ids => users_to_test.keys.map(&:id)
}
} }
) }
assert_response 302 )
end assert_response 302
end end
assert_equal users_to_test.keys.size, ActionMailer::Base.deliveries.size assert_equal users_to_test.keys.size, ActionMailer::Base.deliveries.size
# tests that each user receives 1 email with the custom fields he is allowed to see only # tests that each user receives 1 email with the custom fields he is allowed to see only
users_to_test.each do |user, fields| users_to_test.each do |user, fields|
mails = ActionMailer::Base.deliveries.select {|m| m.bcc.include? user.mail} mails = ActionMailer::Base.deliveries.select {|m| m.to.include? user.mail}
assert_equal 1, mails.size assert_equal 1, mails.size
mail = mails.first mail = mails.first
@fields.each_with_index do |field, i| @fields.each_with_index do |field, i|
@@ -330,26 +328,24 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
end end
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
@request.session[:user_id] = 1 @request.session[:user_id] = 1
with_settings :bcc_recipients => '1' do put(
put( :update,
:update, :params => {
:params => { :id => @issue.id,
:id => @issue.id, :issue => {
:issue => { :custom_field_values => {
:custom_field_values => { @field1.id.to_s => 'NewValue0',
@field1.id.to_s => 'NewValue0', @field2.id.to_s => 'NewValue1',
@field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'
@field3.id.to_s => 'NewValue2'
}
} }
} }
) }
assert_response 302 )
end assert_response 302
assert_equal users_to_test.keys.size, ActionMailer::Base.deliveries.size assert_equal users_to_test.keys.size, ActionMailer::Base.deliveries.size
# tests that each user receives 1 email with the custom fields he is allowed to see only # tests that each user receives 1 email with the custom fields he is allowed to see only
users_to_test.each do |user, fields| users_to_test.each do |user, fields|
mails = ActionMailer::Base.deliveries.select {|m| m.bcc.include? user.mail} mails = ActionMailer::Base.deliveries.select {|m| m.to.include? user.mail}
assert_equal 1, mails.size assert_equal 1, mails.size
mail = mails.first mail = mails.first
@fields.each_with_index do |field, i| @fields.each_with_index do |field, i|
@@ -371,22 +367,20 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
end end
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
@request.session[:user_id] = 1 @request.session[:user_id] = 1
with_settings :bcc_recipients => '1' do put(
put( :update,
:update, :params => {
:params => { :id => @issue.id,
:id => @issue.id, :issue => {
:issue => { :custom_field_values => {
:custom_field_values => { @field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'
@field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'
}
} }
} }
) }
assert_response 302 )
end assert_response 302
users_to_test.each do |user, fields| users_to_test.each do |user, fields|
mails = ActionMailer::Base.deliveries.select {|m| m.bcc.include? user.mail} mails = ActionMailer::Base.deliveries.select {|m| m.to.include? user.mail}
if (fields & [@field2, @field3]).any? if (fields & [@field2, @field3]).any?
assert_equal 1, mails.size, "User #{user.id} was not notified" assert_equal 1, mails.size, "User #{user.id} was not notified"
else else

View File

@@ -159,11 +159,10 @@ class MessagesControllerTest < Redmine::ControllerTest
assert_mail_body_match 'Message body', mail assert_mail_body_match 'Message body', mail
end end
bcc_email_addresses = mails.map(&:bcc).flatten
# author # author
assert_includes bcc_email_addresses, 'jsmith@somenet.foo' assert_equal ['jsmith@somenet.foo'], mails[0].to
# project member # project member
assert_includes bcc_email_addresses, 'dlopper@somenet.foo' assert_equal ['dlopper@somenet.foo'], mails[1].to
end end
def test_get_edit def test_get_edit

View File

@@ -506,8 +506,8 @@ class MyControllerTest < Redmine::ControllerTest
assert_select 'a[href^=?]', 'http://localhost:3000/my/account', :text => 'My account' assert_select 'a[href^=?]', 'http://localhost:3000/my/account', :text => 'My account'
end end
# The old email address should be notified about the change for security purposes # The old email address should be notified about the change for security purposes
assert [mail.bcc, mail.cc].flatten.include?(User.find(2).mail) assert mail.to.include?(User.find(2).mail)
assert [mail.bcc, mail.cc].flatten.include?('foobar@example.com') assert mail.to.include?('foobar@example.com')
end end
def test_my_account_notify_about_high_priority_issues_preference def test_my_account_notify_about_high_priority_issues_preference

View File

@@ -78,14 +78,12 @@ class SettingsControllerTest < Redmine::ControllerTest
post :edit, :params => { post :edit, :params => {
:settings => { :settings => {
:mail_from => 'functional@test.foo', :mail_from => 'functional@test.foo',
:bcc_recipients => '0',
:notified_events => %w(issue_added issue_updated news_added), :notified_events => %w(issue_added issue_updated news_added),
:emails_footer => 'Test footer' :emails_footer => 'Test footer'
} }
} }
assert_redirected_to '/settings' assert_redirected_to '/settings'
assert_equal 'functional@test.foo', Setting.mail_from assert_equal 'functional@test.foo', Setting.mail_from
assert !Setting.bcc_recipients?
assert_equal %w(issue_added issue_updated news_added), Setting.notified_events assert_equal %w(issue_added issue_updated news_added), Setting.notified_events
assert_equal 'Test footer', Setting.emails_footer assert_equal 'Test footer', Setting.emails_footer
end end
@@ -174,9 +172,8 @@ class SettingsControllerTest < Redmine::ControllerTest
assert_select 'a[href^=?]', 'http://localhost:3000/settings' assert_select 'a[href^=?]', 'http://localhost:3000/settings'
end end
# All admins should receive this # All admins should receive this
recipients = [mail.bcc, mail.cc].flatten
User.active.where(admin: true).each do |admin| User.active.where(admin: true).each do |admin|
assert_include admin.mail, recipients assert_include admin.mail, mail.to
end end
end end

View File

@@ -283,25 +283,20 @@ class UsersControllerTest < Redmine::ControllerTest
end end
def test_create def test_create
with_settings :bcc_recipients => '1' do assert_difference 'User.count' do
assert_difference 'User.count' do assert_difference 'ActionMailer::Base.deliveries.size' do
assert_difference 'ActionMailer::Base.deliveries.size' do post :create, :params => {
post( :user => {
:create, :firstname => 'John',
:params => { :lastname => 'Doe',
:user => { :login => 'jdoe',
:firstname => 'John', :password => 'secret123',
:lastname => 'Doe', :password_confirmation => 'secret123',
:login => 'jdoe', :mail => 'jdoe@gmail.com',
:password => 'secret123', :mail_notification => 'none'
:password_confirmation => 'secret123', },
:mail => 'jdoe@gmail.com', :send_information => '1'
:mail_notification => 'none' }
},
:send_information => '1'
}
)
end
end end
end end
@@ -317,7 +312,7 @@ class UsersControllerTest < Redmine::ControllerTest
mail = ActionMailer::Base.deliveries.last mail = ActionMailer::Base.deliveries.last
assert_not_nil mail assert_not_nil mail
assert_equal [user.mail], mail.bcc assert_equal [user.mail], mail.to
assert_mail_body_match 'secret', mail assert_mail_body_match 'secret', mail
end end
@@ -455,7 +450,7 @@ class UsersControllerTest < Redmine::ControllerTest
User.where(admin: true, status: Principal::STATUS_ACTIVE).each do |admin| User.where(admin: true, status: Principal::STATUS_ACTIVE).each do |admin|
assert_not_nil( assert_not_nil(
ActionMailer::Base.deliveries.detect do |mail| ActionMailer::Base.deliveries.detect do |mail|
[mail.bcc, mail.cc].flatten.include?(admin.mail) [mail.to].flatten.include?(admin.mail)
end end
) )
end end
@@ -463,6 +458,7 @@ class UsersControllerTest < Redmine::ControllerTest
def test_create_non_admin_should_not_send_security_notification def test_create_non_admin_should_not_send_security_notification
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
post :create, :params => { post :create, :params => {
:user => { :user => {
:firstname => 'Edgar', :firstname => 'Edgar',
@@ -474,6 +470,7 @@ class UsersControllerTest < Redmine::ControllerTest
:admin => '0' :admin => '0'
} }
} }
assert_nil ActionMailer::Base.deliveries.last assert_nil ActionMailer::Base.deliveries.last
end end
@@ -481,6 +478,7 @@ class UsersControllerTest < Redmine::ControllerTest
with_settings :gravatar_enabled => '1' do with_settings :gravatar_enabled => '1' do
get :edit, :params => {:id => 2} get :edit, :params => {:id => 2}
end end
assert_response :success assert_response :success
assert_select 'h2>a+img.gravatar' assert_select 'h2>a+img.gravatar'
assert_select 'input[name=?][value=?]', 'user[login]', 'jsmith' assert_select 'input[name=?][value=?]', 'user[login]', 'jsmith'
@@ -496,7 +494,9 @@ class UsersControllerTest < Redmine::ControllerTest
def test_edit_should_be_denied_for_anonymous def test_edit_should_be_denied_for_anonymous
assert User.find(6).anonymous? assert User.find(6).anonymous?
get :edit, :params => {:id => 6} get :edit, :params => {:id => 6}
assert_response 404 assert_response 404
end end
@@ -505,16 +505,19 @@ class UsersControllerTest < Redmine::ControllerTest
field.update_attribute :text_formatting, 'full' field.update_attribute :text_formatting, 'full'
get :edit, :params => {:id => 2} get :edit, :params => {:id => 2}
assert_response :success assert_response :success
end end
def test_update def test_update
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
put :update, :params => { put :update, :params => {
:id => 2, :id => 2,
:user => {:firstname => 'Changed', :mail_notification => 'only_assigned'}, :user => {:firstname => 'Changed', :mail_notification => 'only_assigned'},
:pref => {:hide_mail => '1', :comments_sorting => 'desc'} :pref => {:hide_mail => '1', :comments_sorting => 'desc'}
} }
user = User.find(2) user = User.find(2)
assert_equal 'Changed', user.firstname assert_equal 'Changed', user.firstname
assert_equal 'only_assigned', user.mail_notification assert_equal 'only_assigned', user.mail_notification
@@ -539,6 +542,7 @@ class UsersControllerTest < Redmine::ControllerTest
:id => 2, :id => 2,
:user => {:group_ids => ['10']} :user => {:group_ids => ['10']}
} }
user = User.find(2) user = User.find(2)
assert_equal [10], user.group_ids assert_equal [10], user.group_ids
end end
@@ -550,84 +554,81 @@ class UsersControllerTest < Redmine::ControllerTest
u.status = User::STATUS_REGISTERED u.status = User::STATUS_REGISTERED
u.save! u.save!
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
with_settings :bcc_recipients => '1' do
put( put(
:update, :update,
:params => { :params => {
:id => u.id, :id => u.id,
:user => {:status => User::STATUS_ACTIVE} :user => {:status => User::STATUS_ACTIVE}
} }
) )
end
assert u.reload.active? assert u.reload.active?
mail = ActionMailer::Base.deliveries.last mail = ActionMailer::Base.deliveries.last
assert_not_nil mail assert_not_nil mail
assert_equal ['foo.bar@somenet.foo'], mail.bcc assert_equal ['foo.bar@somenet.foo'], mail.to
assert_mail_body_match ll('fr', :notice_account_activated), mail assert_mail_body_match ll('fr', :notice_account_activated), mail
end end
def test_update_with_password_change_should_send_a_notification def test_update_with_password_change_should_send_a_notification
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
with_settings :bcc_recipients => '1' do
put( put(
:update, :update,
:params => { :params => {
:id => 2, :id => 2,
:user => { :user => {
:password => 'newpass123', :password => 'newpass123',
:password_confirmation => 'newpass123' :password_confirmation => 'newpass123'
}, },
:send_information => '1' :send_information => '1'
} }
) )
end
u = User.find(2) u = User.find(2)
assert u.check_password?('newpass123') assert u.check_password?('newpass123')
mail = ActionMailer::Base.deliveries.last mail = ActionMailer::Base.deliveries.last
assert_not_nil mail assert_not_nil mail
assert_equal [u.mail], mail.bcc assert_equal [u.mail], mail.to
assert_mail_body_match 'newpass123', mail assert_mail_body_match 'newpass123', mail
end end
def test_update_with_password_change_by_admin_should_send_a_security_notification def test_update_with_password_change_by_admin_should_send_a_security_notification
with_settings :bcc_recipients => '0' do ActionMailer::Base.deliveries.clear
ActionMailer::Base.deliveries.clear user = User.find_by(login: 'jsmith')
user = User.find_by(login: 'jsmith')
put :update, :params => { put :update, :params => {
:id => user.id, :id => user.id,
:user => {:password => 'newpass123', :password_confirmation => 'newpass123'} :user => {:password => 'newpass123', :password_confirmation => 'newpass123'}
} }
assert_equal 1, ActionMailer::Base.deliveries.size assert_equal 1, ActionMailer::Base.deliveries.size
mail = ActionMailer::Base.deliveries.last mail = ActionMailer::Base.deliveries.last
assert_equal [user.mail], mail.to assert_equal [user.mail], mail.to
assert_match 'Security notification', mail.subject assert_match 'Security notification', mail.subject
assert_mail_body_match 'Your password has been changed.', mail assert_mail_body_match 'Your password has been changed.', mail
end
end end
def test_update_with_generate_password_should_email_the_password def test_update_with_generate_password_should_email_the_password
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
with_settings :bcc_recipients => '1' do
put( put(
:update, :update,
:params => { :params => {
:id => 2, :id => 2,
:user => { :user => {
:generate_password => '1', :generate_password => '1',
:password => '', :password => '',
:password_confirmation => '' :password_confirmation => ''
}, },
:send_information => '1' :send_information => '1'
} }
) )
end
mail = ActionMailer::Base.deliveries.last mail = ActionMailer::Base.deliveries.last
assert_not_nil mail assert_not_nil mail
u = User.find(2) u = User.find(2)
assert_equal [u.mail], mail.bcc assert_equal [u.mail], mail.to
m = mail_body(mail).match(/Password: ([a-zA-Z0-9]+)/) m = mail_body(mail).match(/Password: ([a-zA-Z0-9]+)/)
assert m assert m
password = m[1] password = m[1]
@@ -720,7 +721,7 @@ class UsersControllerTest < Redmine::ControllerTest
User.where(admin: true, status: Principal::STATUS_ACTIVE).each do |admin| User.where(admin: true, status: Principal::STATUS_ACTIVE).each do |admin|
assert_not_nil( assert_not_nil(
ActionMailer::Base.deliveries.detect do |mail| ActionMailer::Base.deliveries.detect do |mail|
[mail.bcc, mail.cc].flatten.include?(admin.mail) [mail.to].flatten.include?(admin.mail)
end end
) )
end end
@@ -750,7 +751,7 @@ class UsersControllerTest < Redmine::ControllerTest
User.where(admin: true, status: Principal::STATUS_ACTIVE).each do |admin| User.where(admin: true, status: Principal::STATUS_ACTIVE).each do |admin|
assert_not_nil( assert_not_nil(
ActionMailer::Base.deliveries.detect do |mail| ActionMailer::Base.deliveries.detect do |mail|
[mail.bcc, mail.cc].flatten.include?(admin.mail) [mail.to].flatten.include?(admin.mail)
end end
) )
end end
@@ -780,7 +781,7 @@ class UsersControllerTest < Redmine::ControllerTest
User.where(admin: true, status: Principal::STATUS_ACTIVE).each do |admin| User.where(admin: true, status: Principal::STATUS_ACTIVE).each do |admin|
assert_not_nil( assert_not_nil(
ActionMailer::Base.deliveries.detect do |mail| ActionMailer::Base.deliveries.detect do |mail|
[mail.bcc, mail.cc].flatten.include?(admin.mail) [mail.to].flatten.include?(admin.mail)
end end
) )
end end
@@ -816,7 +817,7 @@ class UsersControllerTest < Redmine::ControllerTest
User.where(admin: true, status: Principal::STATUS_ACTIVE).each do |admin| User.where(admin: true, status: Principal::STATUS_ACTIVE).each do |admin|
assert_not_nil( assert_not_nil(
ActionMailer::Base.deliveries.detect do |mail| ActionMailer::Base.deliveries.detect do |mail|
[mail.bcc, mail.cc].flatten.include?(admin.mail) [mail.to].flatten.include?(admin.mail)
end end
) )
end end
@@ -928,7 +929,7 @@ class UsersControllerTest < Redmine::ControllerTest
User.where(admin: true, status: Principal::STATUS_ACTIVE).each do |admin| User.where(admin: true, status: Principal::STATUS_ACTIVE).each do |admin|
assert_not_nil( assert_not_nil(
ActionMailer::Base.deliveries.detect do |mail| ActionMailer::Base.deliveries.detect do |mail|
[mail.bcc, mail.cc].flatten.include?(admin.mail) [mail.to].flatten.include?(admin.mail)
end end
) )
end end

View File

@@ -2686,7 +2686,7 @@ class IssueTest < ActiveSupport::TestCase
issue.assigned_to = nil issue.assigned_to = nil
issue.save! issue.save!
assert_include [user.mail], ActionMailer::Base.deliveries.map(&:bcc) assert_include [user.mail], ActionMailer::Base.deliveries.map(&:to)
end end
end end

View File

@@ -324,7 +324,7 @@ class MailerTest < ActiveSupport::TestCase
user.pref.save user.pref.save
User.current = user User.current = user
Mailer.deliver_news_added(news.reload) Mailer.deliver_news_added(news.reload)
assert_equal 1, last_email.bcc.size assert_equal 1, last_email.to.size
# nobody to notify # nobody to notify
user.pref.no_self_notified = true user.pref.no_self_notified = true
@@ -430,8 +430,8 @@ class MailerTest < ActiveSupport::TestCase
issue = Issue.find(1) issue = Issue.find(1)
assert Mailer.deliver_issue_add(issue) assert Mailer.deliver_issue_add(issue)
assert mail = ActionMailer::Base.deliveries.find {|m| m.bcc.include?('dlopper@somenet.foo')} assert mail = ActionMailer::Base.deliveries.find {|m| m.to.include?('dlopper@somenet.foo')}
assert mail.bcc.include?('otheremail@somenet.foo') assert mail.to.include?('otheremail@somenet.foo')
end end
test "#issue_add should not notify project members that are not allow to view the issue" do test "#issue_add should not notify project members that are not allow to view the issue" do
@@ -650,8 +650,8 @@ class MailerTest < ActiveSupport::TestCase
def test_version_file_added def test_version_file_added
attachements = [Attachment.find_by_container_type('Version')] attachements = [Attachment.find_by_container_type('Version')]
assert Mailer.deliver_attachments_added(attachements) assert Mailer.deliver_attachments_added(attachements)
assert_not_nil last_email.bcc assert_not_nil last_email.to
assert last_email.bcc.any? assert last_email.to.any?
assert_select_email do assert_select_email do
assert_select "a[href=?]", "http://localhost:3000/projects/ecookbook/files" assert_select "a[href=?]", "http://localhost:3000/projects/ecookbook/files"
end end
@@ -660,8 +660,8 @@ class MailerTest < ActiveSupport::TestCase
def test_project_file_added def test_project_file_added
attachements = [Attachment.find_by_container_type('Project')] attachements = [Attachment.find_by_container_type('Project')]
assert Mailer.deliver_attachments_added(attachements) assert Mailer.deliver_attachments_added(attachements)
assert_not_nil last_email.bcc assert_not_nil last_email.to
assert last_email.bcc.any? assert last_email.to.any?
assert_select_email do assert_select_email do
assert_select "a[href=?]", "http://localhost:3000/projects/ecookbook/files" assert_select "a[href=?]", "http://localhost:3000/projects/ecookbook/files"
end end
@@ -735,7 +735,7 @@ class MailerTest < ActiveSupport::TestCase
Mailer.reminders(:days => days) Mailer.reminders(:days => days)
assert_equal 1, ActionMailer::Base.deliveries.size assert_equal 1, ActionMailer::Base.deliveries.size
mail = last_email mail = last_email
assert mail.bcc.include?('dlopper@somenet.foo') assert mail.to.include?('dlopper@somenet.foo')
assert_mail_body_match 'Bug #3: Error 281 when updating a recipe (5 days late)', mail assert_mail_body_match 'Bug #3: Error 281 when updating a recipe (5 days late)', mail
assert_mail_body_match 'View all issues (2 open)', mail assert_mail_body_match 'View all issues (2 open)', mail
url = url =
@@ -763,7 +763,7 @@ class MailerTest < ActiveSupport::TestCase
Mailer.reminders(:days => 42) Mailer.reminders(:days => 42)
assert_equal 1, ActionMailer::Base.deliveries.size assert_equal 1, ActionMailer::Base.deliveries.size
mail = last_email mail = last_email
assert mail.bcc.include?('dlopper@somenet.foo') assert mail.to.include?('dlopper@somenet.foo')
assert_mail_body_match( assert_mail_body_match(
'Bug #3: Error 281 when updating a recipe (En retard de 5 jours)', 'Bug #3: Error 281 when updating a recipe (En retard de 5 jours)',
mail mail
@@ -783,7 +783,7 @@ class MailerTest < ActiveSupport::TestCase
Mailer.reminders(:days => 42) Mailer.reminders(:days => 42)
assert_equal 1, ActionMailer::Base.deliveries.size assert_equal 1, ActionMailer::Base.deliveries.size
mail = last_email mail = last_email
assert mail.bcc.include?('dlopper@somenet.foo') assert mail.to.include?('dlopper@somenet.foo')
assert_mail_body_no_match 'Closed issue', mail assert_mail_body_no_match 'Closed issue', mail
end end
end end
@@ -795,7 +795,7 @@ class MailerTest < ActiveSupport::TestCase
Mailer.reminders(:days => 42, :users => ['3']) Mailer.reminders(:days => 42, :users => ['3'])
assert_equal 1, ActionMailer::Base.deliveries.size # No mail for dlopper assert_equal 1, ActionMailer::Base.deliveries.size # No mail for dlopper
mail = last_email mail = last_email
assert mail.bcc.include?('dlopper@somenet.foo') assert mail.to.include?('dlopper@somenet.foo')
assert_mail_body_match 'Bug #3: Error 281 when updating a recipe (5 days late)', mail assert_mail_body_match 'Bug #3: Error 281 when updating a recipe (5 days late)', mail
end end
@@ -828,7 +828,7 @@ class MailerTest < ActiveSupport::TestCase
) )
assert_mail_body_match 'Assigned to group (Due in 5 days)', mail assert_mail_body_match 'Assigned to group (Due in 5 days)', mail
assert_mail_body_match( assert_mail_body_match(
"View all issues (#{mail.bcc.include?('dlopper@somenet.foo') ? 3 : 2} open)", "View all issues (#{mail.to.include?('dlopper@somenet.foo') ? 3 : 2} open)",
mail mail
) )
end end
@@ -1125,7 +1125,7 @@ class MailerTest < ActiveSupport::TestCase
# Returns an array of email addresses to which emails were sent # Returns an array of email addresses to which emails were sent
def recipients def recipients
ActionMailer::Base.deliveries.map(&:bcc).flatten.sort ActionMailer::Base.deliveries.map(&:to).flatten.sort
end end
def last_email def last_email
@@ -1143,6 +1143,6 @@ class MailerTest < ActiveSupport::TestCase
end end
def destination_user(mail) def destination_user(mail)
EmailAddress.where(:address => [mail.to, mail.cc, mail.bcc].flatten).map(&:user).first EmailAddress.where(:address => [mail.to, mail.cc].flatten).map(&:user).first
end end
end end