Project

General

Profile

Feature #35137 » 35137.patch

Yuichi HARADA, 2021-04-21 07:06

View differences:

app/controllers/imports_controller.rb
def settings
if request.post? && @import.parse_file
redirect_to import_mapping_path(@import)
if @import.total_items == 0
flash.now[:error] = l(:error_no_data_import_file)
else
redirect_to import_mapping_path(@import)
end
end
rescue CSV::MalformedCSVError, EncodingError => e
config/locales/en.yml
error_invalid_file_encoding: "The file is not a valid %{encoding} encoded file"
error_invalid_csv_file_or_settings: "The file is not a CSV file or does not match the settings below (%{value})"
error_can_not_read_import_file: "An error occurred while reading the file to import"
error_no_data_import_file: "There is no data to import into the file"
error_attachment_extension_not_allowed: "Attachment extension %{extension} is not allowed"
error_ldap_bind_credentials: "Invalid LDAP Account/Password"
error_no_tracker_allowed_for_new_issue_in_project: "The project doesn't have any trackers for which you can create an issue"
test/fixtures/files/import_issues_only_header_row.csv
priority;Subject;start_date;parent;private;progress;custom;"target version";category;user;estimated_hours;tracker;status;database;cf_6;
test/functional/imports_controller_test.rb
assert_select 'div#flash_error', /The file is not a CSV file or does not match the settings below \([[:print:]]+\)/
end
def test_post_settings_with_only_header_row_should_display_error
import = generate_import('import_issues_only_header_row.csv')
post(
:settings,
:params => {
:id => import.to_param,
:import_settings => {
:separator => ';',
:wrapper => '"',
:encoding => 'ISO-8859-1'
}
}
)
assert_response 200
import.reload
assert_equal 0, import.total_items
assert_select 'div#flash_error', /There is no data to import into the file/
end
def test_get_mapping_should_display_mapping_form
import = generate_import('import_iso8859-1.csv')
import.settings = {'separator' => ";", 'wrapper' => '"', 'encoding' => "ISO-8859-1"}
(2-2/4)