summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2022-02-20 18:51:46 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2022-02-20 18:51:46 +0000
commit5754ee903bf89a59ce36a9b015099839a3a638eb (patch)
treeea726a54d4907aaf6cbb1da57baa8d20d2beee2b
parent31eb388f261aa1fb2c5ab1f1010a4de56c3dea65 (diff)
downloadredmine-5754ee903bf89a59ce36a9b015099839a3a638eb.tar.gz
redmine-5754ee903bf89a59ce36a9b015099839a3a638eb.zip
Merged r21422 to 4.2-stable (#35656).
git-svn-id: http://svn.redmine.org/redmine/branches/4.2-stable@21424 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/issue_import.rb6
-rw-r--r--test/fixtures/files/import_issues_with_relation_and_invalid_issues.csv6
-rw-r--r--test/unit/issue_import_test.rb22
3 files changed, 33 insertions, 1 deletions
diff --git a/app/models/issue_import.rb b/app/models/issue_import.rb
index 9f6edf903..ccfd663e0 100644
--- a/app/models/issue_import.rb
+++ b/app/models/issue_import.rb
@@ -286,7 +286,11 @@ class IssueImport < Import
relation.delay = decl[:delay] if decl[:delay]
- relation.save!
+ begin
+ relation.save!
+ rescue
+ nil
+ end
end
end
end
diff --git a/test/fixtures/files/import_issues_with_relation_and_invalid_issues.csv b/test/fixtures/files/import_issues_with_relation_and_invalid_issues.csv
new file mode 100644
index 000000000..45c901c33
--- /dev/null
+++ b/test/fixtures/files/import_issues_with_relation_and_invalid_issues.csv
@@ -0,0 +1,6 @@
+row;tracker;subject;status;related to;
+1;Feature request;Issue 1;New;;
+2;Feature request;Issue 2;New;1;
+3;Feature request;;New;;This issue failes to import
+4;Feature request;Issue 4;New;3;This import failes to reate the relationsip - import hangs
+5;Feature request;Issue 5;New;;
diff --git a/test/unit/issue_import_test.rb b/test/unit/issue_import_test.rb
index 1a7413890..be4b0b34e 100644
--- a/test/unit/issue_import_test.rb
+++ b/test/unit/issue_import_test.rb
@@ -273,6 +273,28 @@ class IssueImportTest < ActiveSupport::TestCase
assert_equal Date.new(2020, 2, 3), third.due_date
end
+ def test_import_with_relations_and_invalid_issue_should_not_fail
+ import = generate_import_with_mapping('import_issues_with_relation_and_invalid_issues.csv')
+ import.settings['mapping'] = {
+ 'project_id' => '1',
+
+ 'tracker' => '1',
+ 'subject' => '2',
+ 'status' => '3',
+ 'relation_relates' => '4',
+ }
+ import.save!
+
+ first, second, third, fourth = new_records(Issue, 4) {import.run}
+
+ assert_equal 1, import.unsaved_items.count
+ item = import.unsaved_items.first
+ assert_include "Subject cannot be blank", item.message
+
+ assert_equal 1, first.relations_from.count
+ assert_equal 1, second.relations_to.count
+ end
+
def test_assignee_should_be_set
import = generate_import_with_mapping
import.mapping['assigned_to'] = '11'