summaryrefslogtreecommitdiffstats
path: root/test/unit/issue_import_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-06-07 18:23:42 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-06-07 18:23:42 +0000
commite3875ffd5739a60e59f54ff431d2c0bf17f8a55e (patch)
tree1d0fcbd0ad8fb4b155fb0df780403a3765f5f4c9 /test/unit/issue_import_test.rb
parentb935539f287a18924d510de8649f38fffdb85f50 (diff)
downloadredmine-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/unit/issue_import_test.rb')
-rw-r--r--test/unit/issue_import_test.rb33
1 files changed, 32 insertions, 1 deletions
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