]> source.dussan.org Git - redmine.git/commitdiff
Restore the value of Setting.cross_project_issue_relations to prevent random test...
authorGo MAEDA <maeda@farend.jp>
Thu, 13 Jan 2022 00:59:17 +0000 (00:59 +0000)
committerGo MAEDA <maeda@farend.jp>
Thu, 13 Jan 2022 00:59:17 +0000 (00:59 +0000)
Patch by Yuichi HARADA.

git-svn-id: http://svn.redmine.org/redmine/trunk@21363 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/unit/project_copy_test.rb

index 29cac332747079c9907f5bd49e50b0b49f369588..c05d4f430d77fdf8a73e899d6baa55d6070776d8 100644 (file)
@@ -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