summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-03-01 16:20:27 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-03-01 16:20:27 +0000
commitb0fa5e7305f812d61e1a9a02e9181d01035d75f6 (patch)
tree5f01240f40688b1413ffd4789ef6f51c68da7212 /test/unit
parent5bb2f5e211b7641a1b92a088e7250cd33d7d663d (diff)
downloadredmine-b0fa5e7305f812d61e1a9a02e9181d01035d75f6.tar.gz
redmine-b0fa5e7305f812d61e1a9a02e9181d01035d75f6.zip
Merged r11513 from trunk (#13328).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.3-stable@11515 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/issue_test.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index 7f62c136a..1f8ecba09 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -849,6 +849,49 @@ class IssueTest < ActiveSupport::TestCase
assert_equal copy.author, child_copy.author
end
+ def test_copy_as_a_child_of_copied_issue_should_not_copy_itself
+ parent = Issue.generate!
+ child1 = Issue.generate!(:parent_issue_id => parent.id, :subject => 'Child 1')
+ child2 = Issue.generate!(:parent_issue_id => parent.id, :subject => 'Child 2')
+
+ copy = parent.reload.copy
+ copy.parent_issue_id = parent.id
+ copy.author = User.find(7)
+ assert_difference 'Issue.count', 3 do
+ assert copy.save
+ end
+ parent.reload
+ copy.reload
+ assert_equal parent, copy.parent
+ assert_equal 3, parent.children.count
+ assert_equal 5, parent.descendants.count
+ assert_equal 2, copy.children.count
+ assert_equal 2, copy.descendants.count
+ end
+
+ def test_copy_as_a_descendant_of_copied_issue_should_not_copy_itself
+ parent = Issue.generate!
+ child1 = Issue.generate!(:parent_issue_id => parent.id, :subject => 'Child 1')
+ child2 = Issue.generate!(:parent_issue_id => parent.id, :subject => 'Child 2')
+
+ copy = parent.reload.copy
+ copy.parent_issue_id = child1.id
+ copy.author = User.find(7)
+ assert_difference 'Issue.count', 3 do
+ assert copy.save
+ end
+ parent.reload
+ child1.reload
+ copy.reload
+ assert_equal child1, copy.parent
+ assert_equal 2, parent.children.count
+ assert_equal 5, parent.descendants.count
+ assert_equal 1, child1.children.count
+ assert_equal 3, child1.descendants.count
+ assert_equal 2, copy.children.count
+ assert_equal 2, copy.descendants.count
+ end
+
def test_copy_should_copy_subtasks_to_target_project
issue = Issue.generate_with_descendants!