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