IssueRelationsControllerTest#test_bulk_create_should_show_errors assumes that Setting.cross_project_issue_relations?
is false.
When I ran the test, it was true, and although it should have been 3 records registered, 4 records could be registered, so this test failed.
As a result of the investigation, since Setting.cross_project_issue_relations = '1'
was executed in source:trunk/test/unit/project_copy_test.rb@21326#L176, other It was affecting the test.
After creating a patch like the one below, the test was not failed.
diff --git a/test/unit/project_copy_test.rb b/test/unit/project_copy_test.rb
index 50cc1c9c98..91c45f2b10 100644
--- a/test/unit/project_copy_test.rb
+++ b/test/unit/project_copy_test.rb
@@ -173,38 +173,38 @@ class ProjectCopyTest < ActiveSupport::TestCase
end
test "#copy should copy issue relations" do
- Setting.cross_project_issue_relations = '1'
-
- second_issue = Issue.generate!(:status_id => 5,
- :subject => "copy issue relation",
- :tracker_id => 1,
- :assigned_to_id => 2,
- :project_id => @source_project.id)
- source_relation = IssueRelation.create!(:issue_from => Issue.find(4),
+ with_settings :cross_project_issue_relations => '1' do
+ second_issue = Issue.generate!(:status_id => 5,
+ :subject => "copy issue relation",
+ :tracker_id => 1,
+ :assigned_to_id => 2,
+ :project_id => @source_project.id)
+ source_relation = IssueRelation.create!(:issue_from => Issue.find(4),
:issue_to => second_issue,
:relation_type => "relates")
- source_relation_cross_project = IssueRelation.create!(:issue_from => Issue.find(1),
+ source_relation_cross_project = IssueRelation.create!(:issue_from => Issue.find(1),
:issue_to => second_issue,
:relation_type => "duplicates")
- assert @project.copy(@source_project)
- assert_equal @source_project.issues.count, @project.issues.count
- copied_issue = @project.issues.find_by_subject("Issue on project 2") # Was #4
- copied_second_issue = @project.issues.find_by_subject("copy issue relation")
-
- # First issue with a relation on project
- assert_equal 1, copied_issue.relations.size, "Relation not copied"
- copied_relation = copied_issue.relations.first
- assert_equal "relates", copied_relation.relation_type
- assert_equal copied_second_issue.id, copied_relation.issue_to_id
- assert_not_equal source_relation.id, copied_relation.id
-
- # Second issue with a cross project relation
- assert_equal 2, copied_second_issue.relations.size, "Relation not copied"
- copied_relation = copied_second_issue.relations.find {|r| r.relation_type == 'duplicates'}
- assert_equal "duplicates", copied_relation.relation_type
- assert_equal 1, copied_relation.issue_from_id, "Cross project relation not kept"
- assert_not_equal source_relation_cross_project.id, copied_relation.id
+ assert @project.copy(@source_project)
+ assert_equal @source_project.issues.count, @project.issues.count
+ copied_issue = @project.issues.find_by_subject("Issue on project 2") # Was #4
+ copied_second_issue = @project.issues.find_by_subject("copy issue relation")
+
+ # First issue with a relation on project
+ assert_equal 1, copied_issue.relations.size, "Relation not copied"
+ copied_relation = copied_issue.relations.first
+ assert_equal "relates", copied_relation.relation_type
+ assert_equal copied_second_issue.id, copied_relation.issue_to_id
+ assert_not_equal source_relation.id, copied_relation.id
+
+ # Second issue with a cross project relation
+ assert_equal 2, copied_second_issue.relations.size, "Relation not copied"
+ copied_relation = copied_second_issue.relations.find {|r| r.relation_type == 'duplicates'}
+ assert_equal "duplicates", copied_relation.relation_type
+ assert_equal 1, copied_relation.issue_from_id, "Cross project relation not kept"
+ assert_not_equal source_relation_cross_project.id, copied_relation.id
+ end
end
test "#copy should copy issue attachments" do