From 9bfa91ea3854865c5f93ed090eb2f679547ae9ec Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Thu, 13 Jan 2022 00:59:17 +0000 Subject: [PATCH] Restore the value of Setting.cross_project_issue_relations to prevent random test failures (#36361). 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 | 54 +++++++++++++++++----------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/test/unit/project_copy_test.rb b/test/unit/project_copy_test.rb index 29cac3327..c05d4f430 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 -- 2.39.5