Project

General

Profile

Defect #34326 » fixed-34326.patch

Yuichi HARADA, 2020-11-30 08:41

View differences:

app/controllers/imports_controller.rb
173 173
    return if @import.settings['encoding'].blank?
174 174

  
175 175
    mappings = @import.settings['mapping'] ||= {}
176
    headers = @import.headers.map(&:downcase)
176
    headers = @import.headers.map{|header| header.to_s.downcase}
177 177

  
178 178
    # Core fields
179 179
    import_type::AUTO_MAPPABLE_FIELDS.each do |field_nm, label_nm|
test/fixtures/files/import_issues_auto_mapping.csv
1
priority;Subject;start_date;parent;private;progress;custom;"target version";category;user;estimated_hours;tracker;status;database;cf_6
2
High;First;2015-07-08;;no;;PostgreSQL;;New category;dlopper;1;bug;new;"PostgreSQL, Oracle";2
1
priority;;Subject;start_date;parent;private;progress;custom;"target version";category;user;estimated_hours;tracker;status;database;cf_6
2
High;;First;2015-07-08;;no;;PostgreSQL;;New category;dlopper;1;bug;new;"PostgreSQL, Oracle";2
test/functional/imports_controller_test.rb
190 190
    #  - 'Subject' exists in the import file
191 191
    #  - mapping is case insensitive
192 192
    assert_select 'select[name=?]', 'import_settings[mapping][subject]' do
193
      assert_select 'option[value="1"][selected="selected"]', :text => 'Subject'
193
      assert_select 'option[value="2"][selected="selected"]', :text => 'Subject'
194 194
    end
195 195

  
196 196
    # 'estimated_hours' should be auto selected because
197 197
    #  - 'estimated_hours' exists in the import file
198 198
    assert_select 'select[name=?]', 'import_settings[mapping][estimated_hours]' do
199
      assert_select 'option[value="10"][selected="selected"]', :text => 'estimated_hours'
199
      assert_select 'option[value="11"][selected="selected"]', :text => 'estimated_hours'
200 200
    end
201 201

  
202 202
    # 'fixed_version' should be auto selected because
203 203
    #  - the translation 'Target version' exists in the import file
204 204
    assert_select 'select[name=?]', 'import_settings[mapping][fixed_version]' do
205
      assert_select 'option[value="7"][selected="selected"]', :text => 'target version'
205
      assert_select 'option[value="8"][selected="selected"]', :text => 'target version'
206 206
    end
207 207

  
208 208
    # 'assigned_to' should not be auto selected because
......
214 214
    # Custom field 'Float field' should be auto selected because
215 215
    #  - the internal field name ('cf_6') exists in the import file
216 216
    assert_select 'select[name=?]', 'import_settings[mapping][cf_6]' do
217
      assert_select 'option[value="14"][selected="selected"]', :text => 'cf_6'
217
      assert_select 'option[value="15"][selected="selected"]', :text => 'cf_6'
218 218
    end
219 219

  
220 220
    # Custom field 'Database' should be auto selected because
221 221
    #  - field name 'database' exists in the import file
222 222
    #  - mapping is case insensitive
223 223
    assert_select 'select[name=?]', 'import_settings[mapping][cf_1]' do
224
      assert_select 'option[value="13"][selected="selected"]', :text => 'database'
224
      assert_select 'option[value="14"][selected="selected"]', :text => 'database'
225 225
    end
226 226
  end
227 227

  
(2-2/3)