diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-06-07 18:23:42 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-06-07 18:23:42 +0000 |
commit | e3875ffd5739a60e59f54ff431d2c0bf17f8a55e (patch) | |
tree | 1d0fcbd0ad8fb4b155fb0df780403a3765f5f4c9 /test | |
parent | b935539f287a18924d510de8649f38fffdb85f50 (diff) | |
download | redmine-e3875ffd5739a60e59f54ff431d2c0bf17f8a55e.tar.gz redmine-e3875ffd5739a60e59f54ff431d2c0bf17f8a55e.zip |
Make Tracker map-able for CSV import (#22951).
git-svn-id: http://svn.redmine.org/redmine/trunk@15490 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/files/import_issues.csv | 8 | ||||
-rw-r--r-- | test/object_helpers.rb | 2 | ||||
-rw-r--r-- | test/unit/issue_import_test.rb | 33 |
3 files changed, 37 insertions, 6 deletions
diff --git a/test/fixtures/files/import_issues.csv b/test/fixtures/files/import_issues.csv index 918f9fc7e..6990cb534 100644 --- a/test/fixtures/files/import_issues.csv +++ b/test/fixtures/files/import_issues.csv @@ -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 diff --git a/test/object_helpers.rb b/test/object_helpers.rb index 2b3327961..7ea4a619a 100644 --- a/test/object_helpers.rb +++ b/test/object_helpers.rb @@ -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 diff --git a/test/unit/issue_import_test.rb b/test/unit/issue_import_test.rb index 61e100700..6d39214d5 100644 --- a/test/unit/issue_import_test.rb +++ b/test/unit/issue_import_test.rb @@ -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 |