summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-09-08 05:34:07 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-09-08 05:34:07 +0000
commit5003927f13f54850ca9eeac48e353df5e4e325a1 (patch)
tree6af9692d3604e9520af7268f14b728eeed87a120 /test/unit
parentffcf1925e3974e2907aa7baa180bbb2a71952a9d (diff)
downloadredmine-5003927f13f54850ca9eeac48e353df5e4e325a1.tar.gz
redmine-5003927f13f54850ca9eeac48e353df5e4e325a1.zip
Option to copy subtasks when copying issue(s) (#6965).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10327 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/issue_test.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index a3df951a6..59f38dbd8 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -633,6 +633,41 @@ class IssueTest < ActiveSupport::TestCase
assert_equal orig.status, issue.status
end
+ def test_copy_should_copy_subtasks
+ issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
+
+ copy = issue.reload.copy
+ copy.author = User.find(7)
+ assert_difference 'Issue.count', 1+issue.descendants.count do
+ assert copy.save
+ end
+ copy.reload
+ assert_equal %w(Child1 Child2), copy.children.map(&:subject).sort
+ child_copy = copy.children.detect {|c| c.subject == 'Child1'}
+ assert_equal %w(Child11), child_copy.children.map(&:subject).sort
+ assert_equal copy.author, child_copy.author
+ end
+
+ def test_copy_should_copy_subtasks_to_target_project
+ issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
+
+ copy = issue.copy(:project_id => 3)
+ assert_difference 'Issue.count', 1+issue.descendants.count do
+ assert copy.save
+ end
+ assert_equal [3], copy.reload.descendants.map(&:project_id).uniq
+ end
+
+ def test_copy_should_not_copy_subtasks_twice_when_saving_twice
+ issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
+
+ copy = issue.reload.copy
+ assert_difference 'Issue.count', 1+issue.descendants.count do
+ assert copy.save
+ assert copy.save
+ end
+ end
+
def test_should_not_call_after_project_change_on_creation
issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1, :subject => 'Test', :author_id => 1)
issue.expects(:after_project_change).never