use with_settings at UsersControllerTest#test_update_with_generate_password_should_email_the_password

git-svn-id: http://svn.redmine.org/redmine/trunk@20413 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA
2020-11-17 12:41:48 +00:00
parent 14e8f3009c
commit 07935e093d

View File

@@ -592,9 +592,10 @@ class UsersControllerTest < Redmine::ControllerTest
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
Setting.bcc_recipients = '1' with_settings :bcc_recipients => '1' do
put(
put :update, :params => { :update,
:params => {
:id => 2, :id => 2,
:user => { :user => {
:generate_password => '1', :generate_password => '1',
@@ -603,13 +604,16 @@ class UsersControllerTest < Redmine::ControllerTest
}, },
: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)
assert_equal [u.mail], mail.bcc
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]
assert User.find(2).check_password?(password) assert u.check_password?(password)
end end
def test_update_without_generate_password_should_not_change_password def test_update_without_generate_password_should_not_change_password