mirror of
https://github.com/redmine/redmine.git
synced 2026-09-01 05:17:03 +02:00
Make Tracker map-able for CSV import (#22951).
git-svn-id: http://svn.redmine.org/redmine/trunk@15490 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
8
test/fixtures/files/import_issues.csv
vendored
8
test/fixtures/files/import_issues.csv
vendored
@@ -1,4 +1,4 @@
|
||||
priority;subject;description;start_date;due_date;parent;private;progress;custom;version;category;user;estimated_hours
|
||||
High;First;First description;2015-07-08;2015-08-25;;no;;PostgreSQL;;New category;dlopper;1
|
||||
Normal;Child 1;Child description;;;1;yes;10;MySQL;2.0;New category;;2
|
||||
Normal;Child of existing issue;Child description;;;#2;no;20;;2.1;Printing;;3
|
||||
priority;subject;description;start_date;due_date;parent;private;progress;custom;version;category;user;estimated_hours;tracker
|
||||
High;First;First description;2015-07-08;2015-08-25;;no;;PostgreSQL;;New category;dlopper;1;bug
|
||||
Normal;Child 1;Child description;;;1;yes;10;MySQL;2.0;New category;;2;feature request
|
||||
Normal;Child of existing issue;Child description;;;#2;no;20;;2.1;Printing;;3;bug
|
||||
|
||||
|
@@ -235,7 +235,7 @@ module ObjectHelpers
|
||||
|
||||
import.settings = {
|
||||
'separator' => ";", 'wrapper' => '"', 'encoding' => "UTF-8",
|
||||
'mapping' => {'project_id' => '1', 'tracker_id' => '2', 'subject' => '1'}
|
||||
'mapping' => {'project_id' => '1', 'tracker' => '13', 'subject' => '1'}
|
||||
}
|
||||
import.save!
|
||||
import
|
||||
|
||||
@@ -58,6 +58,37 @@ class IssueImportTest < ActiveSupport::TestCase
|
||||
assert_equal 'New category', category.name
|
||||
end
|
||||
|
||||
def test_mapping_with_fixed_tracker
|
||||
import = generate_import_with_mapping
|
||||
import.mapping.merge!('tracker' => 'value:2')
|
||||
import.save!
|
||||
|
||||
issues = new_records(Issue, 3) { import.run }
|
||||
assert_equal [2], issues.map(&:tracker_id).uniq
|
||||
end
|
||||
|
||||
def test_mapping_with_mapped_tracker
|
||||
import = generate_import_with_mapping
|
||||
import.mapping.merge!('tracker' => '13')
|
||||
import.save!
|
||||
|
||||
issues = new_records(Issue, 3) { import.run }
|
||||
assert_equal [1, 2, 1], issues.map(&:tracker_id)
|
||||
end
|
||||
|
||||
def test_should_not_import_with_default_tracker_when_tracker_is_invalid
|
||||
Tracker.find_by_name('Feature request').update!(:name => 'Feature')
|
||||
|
||||
import = generate_import_with_mapping
|
||||
import.mapping.merge!('tracker' => '13')
|
||||
import.save!
|
||||
import.run
|
||||
|
||||
assert_equal 1, import.unsaved_items.count
|
||||
item = import.unsaved_items.first
|
||||
assert_include "Tracker cannot be blank", item.message
|
||||
end
|
||||
|
||||
def test_parent_should_be_set
|
||||
import = generate_import_with_mapping
|
||||
import.mapping.merge!('parent_issue_id' => '5')
|
||||
@@ -101,7 +132,7 @@ class IssueImportTest < ActiveSupport::TestCase
|
||||
field = IssueCustomField.generate!(:field_format => 'date', :is_for_all => true, :trackers => Tracker.all)
|
||||
import = generate_import_with_mapping('import_dates.csv')
|
||||
import.settings.merge!('date_format' => Import::DATE_FORMATS[1])
|
||||
import.mapping.merge!('subject' => '0', 'start_date' => '1', 'due_date' => '2', "cf_#{field.id}" => '3')
|
||||
import.mapping.merge!('tracker' => 'value:1', 'subject' => '0', 'start_date' => '1', 'due_date' => '2', "cf_#{field.id}" => '3')
|
||||
import.save!
|
||||
|
||||
issue = new_record(Issue) { import.run } # only 1 valid issue
|
||||
|
||||
Reference in New Issue
Block a user