1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-02-05 16:43:25 +00:00

Allow sending account information when importing users (#35365).

Patch by Yuichi HARADA.


git-svn-id: http://svn.redmine.org/redmine/trunk@21058 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2021-07-03 09:40:05 +00:00
parent 504e9f3489
commit 41b22756d2
2 changed files with 22 additions and 0 deletions

View File

@ -115,4 +115,8 @@ class UserImport < Import
object.send(:safe_attributes=, attributes, user)
object
end
def extend_object(row, item, object)
Mailer.deliver_account_information(object, object.password) if yes?(settings['notifications'])
end
end

View File

@ -130,6 +130,24 @@ class UserImportTest < ActiveSupport::TestCase
assert_equal '666-7777-8888', third.custom_field_value(phone_number_cf)
end
def test_deliver_account_information
import = generate_import_with_mapping
import.settings['notifications'] = '1'
%w(admin language auth_source).each do |key|
import.settings['mapping'].delete(key)
end
import.save!
ActionMailer::Base.deliveries.clear
first, = new_records(User, 3){import.run}
assert_equal 3, ActionMailer::Base.deliveries.size
mail = ActionMailer::Base.deliveries.first
assert_equal 'Your Redmine account activation', mail.subject
assert_equal 'user1', first.login
assert_mail_body_match "Login: #{first.login}", mail
end
protected
def generate_import(fixture_name='import_users.csv')