Feature #22771 » 22771-add-option-email-notification.patch
| app/models/import.rb | ||
|---|---|---|
|
'separator' => separator,
|
||
|
'wrapper' => wrapper,
|
||
|
'encoding' => encoding,
|
||
|
'date_format' => date_format
|
||
|
'date_format' => date_format,
|
||
|
'mail_notification' => '0'
|
||
|
)
|
||
|
end
|
||
| app/models/issue_import.rb | ||
|---|---|---|
|
def build_object(row, item)
|
||
|
issue = Issue.new
|
||
|
issue.author = user
|
||
|
issue.notify = false
|
||
|
issue.notify = !!ActiveRecord::Type::Boolean.new.cast(settings['mail_notification'])
|
||
|
tracker_id = nil
|
||
|
if tracker
|
||
| app/views/imports/settings.html.erb | ||
|---|---|---|
|
<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>
|
||
|
<hr/>
|
||
|
<p>
|
||
|
<label for="import_settings_mail_notification"><%= l(:field_mail_notification) %></label>
|
||
|
<%= hidden_field_tag 'import_settings[mail_notification]', '0', :id => nil %>
|
||
|
<%= check_box_tag 'import_settings[mail_notification]', '1', "#{@import.settings['mail_notification']}" == '1' %>
|
||
|
</p>
|
||
|
</fieldset>
|
||
|
<p><%= submit_tag l(:label_next).html_safe + " »".html_safe, :name => nil %></p>
|
||
|
<% end %>
|
||
| test/functional/imports_controller_test.rb | ||
|---|---|---|
|
:mapping => {
|
||
|
:project_id => '1',
|
||
|
:tracker_id => '2',
|
||
|
:subject => '0'}
|
||
|
:subject => '0'}
|
||
|
}
|
||
|
}
|
||
|
assert_redirected_to "/imports/#{import.to_param}/run"
|
||
| ... | ... | |
|
assert_equal '2', mapping['tracker_id']
|
||
|
assert_equal '0', mapping['subject']
|
||
|
end
|
||
|
|
||
|
def test_get_run
|
||
|
import = generate_import_with_mapping
|
||
| ... | ... | |
|
assert_response :success
|
||
|
assert_select '#import-progress'
|
||
|
end
|
||
|
|
||
|
def test_post_run_should_import_the_file
|
||
|
import = generate_import_with_mapping
|
||
| ... | ... | |
|
assert_equal ["Child of existing issue", "Child 1", "First"], issues.map(&:subject)
|
||
|
end
|
||
|
def test_post_run_with_mail_notification
|
||
|
import = generate_import
|
||
|
post :settings, :params => {
|
||
|
:id => import,
|
||
|
:import_settings => {
|
||
|
:separator => ';',
|
||
|
:wrapper => '"',
|
||
|
:encoding => 'ISO-8859-1',
|
||
|
:mail_notification => '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_countof_mail = ActionMailer::Base.deliveries.size
|
||
|
assert_not_equal 0, actual_countof_mail
|
||
|
import.reload
|
||
|
issue_ids = import.items.collect(&:obj_id)
|
||
|
expect_countof_user =
|
||
|
Issue.where(:id => issue_ids).inject(0) do |_, issue|
|
||
|
_ + (issue.notified_users | issue.notified_watchers).size
|
||
|
end
|
||
|
assert_equal expect_countof_user, actual_countof_mail
|
||
|
end
|
||
|
def test_show_without_errors
|
||
|
import = generate_import_with_mapping
|
||
|
import.run
|
||