summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-05-12 08:33:21 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-05-12 08:33:21 +0000
commit78dc37d8af13e25cd5fc0883afa7c73a34d209a2 (patch)
tree5be94fd3a1bb1ddca87e11384400deb2b305f572 /test/unit
parentef153a5bca8a3e5fb0231be75feaf14eeb05c507 (diff)
downloadredmine-78dc37d8af13e25cd5fc0883afa7c73a34d209a2.tar.gz
redmine-78dc37d8af13e25cd5fc0883afa7c73a34d209a2.zip
Improved Issue#all_dependent_issues (#14015).
Patch by Jost Baron. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11827 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/issue_test.rb130
1 files changed, 130 insertions, 0 deletions
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index 50f9e0437..075bae287 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -1795,6 +1795,136 @@ class IssueTest < ActiveSupport::TestCase
assert_equal [2, 3, 8], Issue.find(1).all_dependent_issues.collect(&:id).sort
end
+ def test_all_dependent_issues_with_subtask
+ IssueRelation.delete_all
+
+ project = Project.generate!(:name => "testproject")
+
+ parentIssue = Issue.generate!(:project => project)
+ childIssue1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue.id)
+ childIssue2 = Issue.generate!(:project => project, :parent_issue_id => parentIssue.id)
+
+ assert_equal [childIssue1.id, childIssue2.id].sort, parentIssue.all_dependent_issues.collect(&:id).uniq.sort
+ end
+
+ def test_all_dependent_issues_does_not_include_self
+ IssueRelation.delete_all
+
+ project = Project.generate!(:name => "testproject")
+
+ parentIssue = Issue.generate!(:project => project)
+ childIssue = Issue.generate!(:project => project, :parent_issue_id => parentIssue.id)
+
+ assert_equal [childIssue.id], parentIssue.all_dependent_issues.collect(&:id)
+ end
+
+ def test_all_dependent_issues_with_parenttask_and_sibling
+ IssueRelation.delete_all
+
+ project = Project.generate!(:name => "testproject")
+
+ parentIssue = Issue.generate!(:project => project)
+ childIssue1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue.id)
+ childIssue2 = Issue.generate!(:project => project, :parent_issue_id => parentIssue.id)
+
+ assert_equal [parentIssue.id].sort, childIssue1.all_dependent_issues.collect(&:id)
+ end
+
+ def test_all_dependent_issues_with_relation_to_leaf_in_other_tree
+ IssueRelation.delete_all
+
+ project = Project.generate!(:name => "testproject")
+
+ parentIssue1 = Issue.generate!(:project => project)
+ childIssue1_1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue1.id)
+ childIssue1_2 = Issue.generate!(:project => project, :parent_issue_id => parentIssue1.id)
+
+ parentIssue2 = Issue.generate!(:project => project)
+ childIssue2_1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue2.id)
+ childIssue2_2 = Issue.generate!(:project => project, :parent_issue_id => parentIssue2.id)
+
+
+ assert IssueRelation.create(:issue_from => parentIssue1,
+ :issue_to => childIssue2_2,
+ :relation_type => IssueRelation::TYPE_BLOCKS)
+
+ assert_equal [childIssue1_1.id, childIssue1_2.id, parentIssue2.id, childIssue2_2.id].sort,
+ parentIssue1.all_dependent_issues.collect(&:id).uniq.sort
+ end
+
+ def test_all_dependent_issues_with_relation_to_parent_in_other_tree
+ IssueRelation.delete_all
+
+ project = Project.generate!(:name => "testproject")
+
+ parentIssue1 = Issue.generate!(:project => project)
+ childIssue1_1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue1.id)
+ childIssue1_2 = Issue.generate!(:project => project, :parent_issue_id => parentIssue1.id)
+
+ parentIssue2 = Issue.generate!(:project => project)
+ childIssue2_1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue2.id)
+ childIssue2_2 = Issue.generate!(:project => project, :parent_issue_id => parentIssue2.id)
+
+
+ assert IssueRelation.create(:issue_from => parentIssue1,
+ :issue_to => parentIssue2,
+ :relation_type => IssueRelation::TYPE_BLOCKS)
+
+ assert_equal [childIssue1_1.id, childIssue1_2.id, parentIssue2.id, childIssue2_1.id, childIssue2_2.id].sort,
+ parentIssue1.all_dependent_issues.collect(&:id).uniq.sort
+ end
+
+ def test_all_dependent_issues_with_transitive_relation
+ IssueRelation.delete_all
+
+ project = Project.generate!(:name => "testproject")
+
+ parentIssue1 = Issue.generate!(:project => project)
+ childIssue1_1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue1.id)
+
+ parentIssue2 = Issue.generate!(:project => project)
+ childIssue2_1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue2.id)
+
+ independentIssue = Issue.generate!(:project => project)
+
+ assert IssueRelation.create(:issue_from => parentIssue1,
+ :issue_to => childIssue2_1,
+ :relation_type => IssueRelation::TYPE_RELATES)
+
+ assert IssueRelation.create(:issue_from => childIssue2_1,
+ :issue_to => independentIssue,
+ :relation_type => IssueRelation::TYPE_RELATES)
+
+ assert_equal [childIssue1_1.id, parentIssue2.id, childIssue2_1.id, independentIssue.id].sort,
+ parentIssue1.all_dependent_issues.collect(&:id).uniq.sort
+ end
+
+ def test_all_dependent_issues_with_transitive_relation2
+ IssueRelation.delete_all
+
+ project = Project.generate!(:name => "testproject")
+
+ parentIssue1 = Issue.generate!(:project => project)
+ childIssue1_1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue1.id)
+
+ parentIssue2 = Issue.generate!(:project => project)
+ childIssue2_1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue2.id)
+
+ independentIssue = Issue.generate!(:project => project)
+
+ assert IssueRelation.create(:issue_from => parentIssue1,
+ :issue_to => independentIssue,
+ :relation_type => IssueRelation::TYPE_RELATES)
+
+ assert IssueRelation.create(:issue_from => independentIssue,
+ :issue_to => childIssue2_1,
+ :relation_type => IssueRelation::TYPE_RELATES)
+
+ assert_equal [childIssue1_1.id, parentIssue2.id, childIssue2_1.id, independentIssue.id].sort,
+ parentIssue1.all_dependent_issues.collect(&:id).uniq.sort
+
+ end
+
def test_all_dependent_issues_with_persistent_circular_dependency
IssueRelation.delete_all
assert IssueRelation.create!(:issue_from => Issue.find(1),