Allow Unique ID and relation fields to be auto mapped (#35131).

Patch by Marius BALTEANU.


git-svn-id: http://svn.redmine.org/redmine/trunk@20968 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2021-04-23 03:53:53 +00:00
parent 137b41cf38
commit d67ed93f39
3 changed files with 25 additions and 3 deletions

View File

@@ -32,7 +32,17 @@ class IssueImport < Import
'start_date' => 'field_start_date',
'due_date' => 'field_due_date',
'estimated_hours' => 'field_estimated_hours',
'done_ratio' => 'field_done_ratio'
'done_ratio' => 'field_done_ratio',
'unique_id' => 'field_unique_id',
'relation_duplicates' => 'label_duplicates',
'relation_duplicated' => 'label_duplicated_by',
'relation_blocks' => 'label_blocks',
'relation_blocked' => 'label_blocked_by',
'relation_relates' => 'label_relates_to',
'relation_precedes' => 'label_precedes',
'relation_follows' => 'label_follows',
'relation_copied_to' => 'label_copied_to',
'relation_copied_from' => 'label_copied_from'
}
def self.menu_item

View File

@@ -1,2 +1,2 @@
priority;Subject;start_date;parent;private;progress;custom;"target version";category;user;estimated_hours;tracker;status;database;cf_6;
High;First;2015-07-08;;no;;PostgreSQL;;New category;dlopper;1;bug;new;"PostgreSQL, Oracle";2;"Column with empty header"
priority;Subject;start_date;parent;private;progress;custom;"target version";category;user;estimated_hours;tracker;status;database;cf_6;unique_id;"Is duplicate of"
High;First;2015-07-08;;no;;PostgreSQL;;New category;dlopper;1;bug;new;"PostgreSQL, Oracle";2;1;4;"Column with empty header"
Can't render this file because it has a wrong number of fields in line 2.

View File

@@ -244,6 +244,18 @@ class ImportsControllerTest < Redmine::ControllerTest
assert_select 'select[name=?]', 'import_settings[mapping][cf_1]' do
assert_select 'option[value="13"][selected="selected"]', :text => 'database'
end
# 'unique_id' should be auto selected because
# - 'unique_id' exists in the import file
assert_select 'select[name=?]', 'import_settings[mapping][unique_id]' do
assert_select 'option[value="15"][selected="selected"]', :text => 'unique_id'
end
# 'relation_duplicates' should be auto selected because
# - 'Is duplicate of' exists in the import file
assert_select 'select[name=?]', 'import_settings[mapping][relation_duplicates]' do
assert_select 'option[value="16"][selected="selected"]', :text => 'Is duplicate of'
end
end
def test_post_mapping_should_update_mapping