]> source.dussan.org Git - redmine.git/commitdiff
Allow sending account information when importing users (#35365).
authorGo MAEDA <maeda@farend.jp>
Sat, 3 Jul 2021 09:40:05 +0000 (09:40 +0000)
committerGo MAEDA <maeda@farend.jp>
Sat, 3 Jul 2021 09:40:05 +0000 (09:40 +0000)
Patch by Yuichi HARADA.

git-svn-id: http://svn.redmine.org/redmine/trunk@21058 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/user_import.rb
test/unit/user_import_test.rb

index 71407c14e31f7e1865bfe2dbd72b40c11df5698e..609c9b078f9effeed3a2f790ff967e87928772d4 100644 (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
index 733d41415fe4ee7e34c79453789646bdb9aa6d94..bf6f73457751296ec4e572c680a801e7c138b12f 100644 (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')