1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-02-01 03:57:15 +00:00

Option to send email notifications while importing issues from CSV files (#22771).

Patch by Yuichi HARADA.


git-svn-id: http://svn.redmine.org/redmine/trunk@18153 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2019-05-10 00:54:52 +00:00
parent 1727950c18
commit a1c40d146a
5 changed files with 48 additions and 2 deletions

View File

@ -80,7 +80,8 @@ class Import < ActiveRecord::Base
'separator' => separator,
'wrapper' => wrapper,
'encoding' => encoding,
'date_format' => date_format
'date_format' => date_format,
'notifications' => '0'
)
end

View File

@ -86,7 +86,7 @@ class IssueImport < Import
def build_object(row, item)
issue = Issue.new
issue.author = user
issue.notify = false
issue.notify = !!ActiveRecord::Type::Boolean.new.cast(settings['notifications'])
tracker_id = nil
if tracker

View File

@ -21,6 +21,12 @@
<label for="import_settings_date_format"><%= l(:setting_date_format) %></label>
<%= select_tag 'import_settings[date_format]', options_for_select(date_format_options, @import.settings['date_format']) %>
</p>
<br>
<p>
<label for="import_settings_notifications"><%= l(:label_import_notifications) %></label>
<%= hidden_field_tag 'import_settings[notifications]', '0', :id => nil %>
<%= check_box_tag 'import_settings[notifications]', '1', "#{@import.settings['notifications']}" == '1' %>
</p>
</fieldset>
<p><%= submit_tag l(:label_next).html_safe + " &#187;".html_safe, :name => nil %></p>
<% end %>

View File

@ -950,6 +950,7 @@ en:
label_profile: Profile
label_subtask_plural: Subtasks
label_project_copy_notifications: Send email notifications during the project copy
label_import_notifications: Send email notifications during the import
label_principal_search: "Search for user or group:"
label_user_search: "Search for user:"
label_additional_workflow_transitions_for_author: Additional transitions allowed when the user is the author

View File

@ -237,6 +237,44 @@ class ImportsControllerTest < Redmine::ControllerTest
assert_equal ["Child of existing issue", "Child 1", "First"], issues.map(&:subject)
end
def test_post_run_with_notifications
import = generate_import
post :settings, :params => {
:id => import,
:import_settings => {
:separator => ';',
:wrapper => '"',
:encoding => 'ISO-8859-1',
:notifications => '1',
:mapping => {
:project_id => '1',
:tracker => '13',
:subject => '1',
:assigned_to => '11',
},
},
}
ActionMailer::Base.deliveries.clear
assert_difference 'Issue.count', 3 do
post :run, :params => {
:id => import,
}
assert_response :found
end
actual_email_count = ActionMailer::Base.deliveries.size
assert_not_equal 0, actual_email_count
import.reload
issue_ids = import.items.collect(&:obj_id)
expected_email_count =
Issue.where(:id => issue_ids).inject(0) do |sum, issue|
sum + (issue.notified_users | issue.notified_watchers).size
end
assert_equal expected_email_count, actual_email_count
end
def test_show_without_errors
import = generate_import_with_mapping
import.run