end
def test_new_should_display_the_upload_form
- get :new, :params => { :type => 'IssueImport', :project_id => 'subproject1' }
+ get(:new, :params => {:type => 'IssueImport', :project_id => 'subproject1'})
assert_response :success
assert_select 'input[name=?]', 'file'
assert_select 'input[name=?][type=?][value=?]', 'project_id', 'hidden', 'subproject1'
def test_create_should_save_the_file
import = new_record(Import) do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:type => 'IssueImport',
:file => uploaded_test_file('import_issues.csv', 'text/csv')
}
+ )
assert_response 302
end
assert_equal 2, import.user_id
def test_get_settings_should_display_settings_form
import = generate_import
- get :settings, :params => {
- :id => import.to_param
- }
+ get(:settings, :params => {:id => import.to_param})
assert_response :success
assert_select 'select[name=?]', 'import_settings[separator]'
assert_select 'select[name=?]', 'import_settings[wrapper]'
def test_post_settings_should_update_settings
import = generate_import
- post :settings, :params => {
+ post(
+ :settings,
+ :params => {
:id => import.to_param,
:import_settings => {
:separator => ":",
:date_format => '%m/%d/%Y'
}
}
+ )
assert_redirected_to "/imports/#{import.to_param}/mapping"
import.reload
def test_post_settings_should_update_total_items_count
import = generate_import('import_iso8859-1.csv')
- post :settings, :params => {
+ post(
+ :settings,
+ :params => {
:id => import.to_param,
:import_settings => {
:separator => ";",
:encoding => "ISO-8859-1"
}
}
+ )
assert_response 302
import.reload
assert_equal 2, import.total_items
def test_post_settings_with_wrong_encoding_should_display_error
import = generate_import('import_iso8859-1.csv')
- post :settings, :params => {
+ post(
+ :settings,
+ :params => {
:id => import.to_param,
:import_settings => {
:separator => ";",
:encoding => "UTF-8"
}
}
+ )
assert_response 200
import.reload
assert_nil import.total_items
def test_post_settings_with_invalid_encoding_should_display_error
import = generate_import('invalid-Shift_JIS.csv')
- post :settings, :params => {
+ post(
+ :settings,
+ :params => {
:id => import.to_param,
:import_settings => {
:separator => ";",
:encoding => "Shift_JIS"
}
}
+ )
assert_response 200
import.reload
assert_nil import.total_items
import.settings = {'separator' => ";", 'wrapper' => '"', 'encoding' => "ISO-8859-1"}
import.save!
- get :mapping, :params => {
- :id => import.to_param
- }
+ get(:mapping, :params => {:id => import.to_param})
assert_response :success
assert_select 'select[name=?]', 'import_settings[mapping][subject]' do
import.settings = {'separator' => ';', 'wrapper'=> '"', 'encoding' => 'ISO-8859-1'}
import.save!
- get :mapping, :params => {
- :id => import.to_param
- }
+ get(:mapping, :params => {:id => import.to_param})
assert_response :success
# 'subject' should be auto selected because
def test_post_mapping_should_update_mapping
import = generate_import('import_iso8859-1.csv')
- post :mapping, :params => {
+ post(
+ :mapping,
+ :params => {
:id => import.to_param,
:import_settings => {
:mapping => {
:project_id => '1',
:tracker_id => '2',
- :subject => '0'}
+ :subject => '0'
+ }
}
}
+ )
assert_redirected_to "/imports/#{import.to_param}/run"
import.reload
mapping = import.settings['mapping']
import.settings = {'separator' => ";", 'wrapper' => '"', 'encoding' => "ISO-8859-1"}
import.save!
- get :mapping, :params => {
- :id => import.to_param
- }
+ get(:mapping, :params => {:id => import.to_param})
assert_response :success
}
import.save!
- get :mapping, :params => {
- :id => import.to_param
- }
+ get(:mapping, :params => {:id => import.to_param})
# 'user' field should be available because User#2 has both
# 'import_time_entries' and 'log_time_for_other_users' permissions
import.settings = {'separator' => ";", 'wrapper' => '"', 'encoding' => "ISO-8859-1"}
import.save!
- get :mapping, :params => {
- :id => import.to_param
- }
+ get(:mapping, :params => {:id => import.to_param})
assert_response :success
def test_get_run
import = generate_import_with_mapping
- get :run, :params => {
- :id => import
- }
+ get(:run, :params => {:id => import})
assert_response :success
assert_select '#import-progress'
end
import = generate_import_with_mapping
assert_difference 'Issue.count', 3 do
- post :run, :params => {
- :id => import
- }
+ post(:run, :params => {:id => import})
assert_redirected_to "/imports/#{import.to_param}"
end
import = generate_import_with_mapping
assert_difference 'Issue.count', 2 do
- post :run, :params => {
- :id => import
- }
+ post(:run, :params => {:id => import})
assert_redirected_to "/imports/#{import.to_param}/run"
end
assert_difference 'Issue.count', 1 do
- post :run, :params => {
- :id => import
- }
+ post(:run, :params => {:id => import})
assert_redirected_to "/imports/#{import.to_param}"
end
def test_post_run_with_notifications
import = generate_import
- post :settings, :params => {
+ post(
+ :settings,
+ :params => {
:id => import,
:import_settings => {
:separator => ';',
:tracker => '13',
:subject => '1',
:assigned_to => '11',
- },
- },
+ }
+ }
}
-
+ )
ActionMailer::Base.deliveries.clear
assert_difference 'Issue.count', 3 do
- post :run, :params => {
- :id => import,
- }
+ post(:run, :params => {:id => import,})
assert_response :found
end
actual_email_count = ActionMailer::Base.deliveries.size
import.run
assert_equal 0, import.unsaved_items.count
- get :show, :params => {
- :id => import.to_param
- }
+ get(:show, :params => {:id => import.to_param})
assert_response :success
assert_select 'ul#saved-items'
import.run
assert_not_equal 0, import.unsaved_items.count
- get :show, :params => {
- :id => import.to_param
- }
+ get(:show, :params => {:id => import.to_param})
assert_response :success
assert_select 'table#unsaved-items'