Feature #35365 ยป 35365.patch
| app/models/user_import.rb | ||
|---|---|---|
| 115 | 115 |
object.send(:safe_attributes=, attributes, user) |
| 116 | 116 |
object |
| 117 | 117 |
end |
| 118 | ||
| 119 |
def extend_object(row, item, object) |
|
| 120 |
Mailer.deliver_account_information(object, object.password) if yes?(settings['notifications']) |
|
| 121 |
end |
|
| 118 | 122 |
end |
| test/unit/user_import_test.rb | ||
|---|---|---|
| 130 | 130 |
assert_equal '666-7777-8888', third.custom_field_value(phone_number_cf) |
| 131 | 131 |
end |
| 132 | 132 | |
| 133 |
def test_notification_should_deliver_account_information |
|
| 134 |
import = generate_import_with_mapping |
|
| 135 |
import.settings['notifications'] = '1' |
|
| 136 |
%w(admin language auth_source).each do |key| |
|
| 137 |
import.settings['mapping'].delete(key) |
|
| 138 |
end |
|
| 139 |
import.save! |
|
| 140 | ||
| 141 |
ActionMailer::Base.deliveries.clear |
|
| 142 |
first, = new_records(User, 3){import.run}
|
|
| 143 |
assert_equal 3, ActionMailer::Base.deliveries.size |
|
| 144 | ||
| 145 |
mail = ActionMailer::Base.deliveries.first |
|
| 146 |
assert_equal 'Your Redmine account activation', mail.subject |
|
| 147 |
assert_equal 'user1', first.login |
|
| 148 |
assert_mail_body_match "Login: #{first.login}", mail
|
|
| 149 |
end |
|
| 150 | ||
| 133 | 151 |
protected |
| 134 | 152 | |
| 135 | 153 |
def generate_import(fixture_name='import_users.csv') |