Project

General

Profile

Patch #30412 » 30412.patch

Felix Schäfer, 2019-01-12 00:52

View differences:

app/models/import.rb
217 217

  
218 218
    csv_options = {:headers => false}
219 219
    csv_options[:encoding] = settings['encoding'].to_s.presence || 'UTF-8'
220
    csv_options[:encoding] = 'bom|UTF-8' if csv_options[:encoding] == 'UTF-8'
220 221
    separator = settings['separator'].to_s
221 222
    csv_options[:col_sep] = separator if separator.size == 1
222 223
    wrapper = settings['wrapper'].to_s
test/fixtures/files/import_issues_utf8_with_bom.csv
1
"priority";subject;description;start_date;due_date;parent;private;progress;custom;version;category;user;estimated_hours;tracker;status
2
High;First;First description;2015-07-08;2015-08-25;;no;;PostgreSQL;;New category;dlopper;1;bug;new
3
Normal;Child 1;Child description;;;1;yes;10;MySQL;2.0;New category;;2;feature request;new
4
Normal;Child of existing issue;Child description;;;#2;no;20;;2.1;Printing;;3;bug;assigned
test/unit/issue_import_test.rb
116 116
    assert_equal 2, issues[2].parent_id
117 117
  end
118 118

  
119
  def test_import_utf8_with_bom
120
    import = generate_import_with_mapping('import_issues_utf8_with_bom.csv')
121
    import.settings.merge!('encoding' => 'UTF-8')
122
    import.save
123

  
124
    issues = new_records(Issue,3) { import.run }
125
    assert_equal 3, issues.count
126
  end
127

  
119 128
  def test_backward_and_forward_reference_to_parent_should_work
120 129
    import = generate_import('import_subtasks.csv')
121 130
    import.settings = {
    (1-1/1)