summaryrefslogtreecommitdiffstats
path: root/test/unit/issue_nested_set_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-01-22 11:46:15 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-01-22 11:46:15 +0000
commit419b195019a276513d1d58a0ed7d7a18c58425be (patch)
tree2caea3a0a8bf97fc06be9441befa30cf78d5ff9b /test/unit/issue_nested_set_test.rb
parentccdea234ad655fab8125e34c0bbad7d27accc886 (diff)
downloadredmine-419b195019a276513d1d58a0ed7d7a18c58425be.tar.gz
redmine-419b195019a276513d1d58a0ed7d7a18c58425be.zip
Fixed: subtasks are deleted (not destroyed) when destroying parent issue (#7385).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4735 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/issue_nested_set_test.rb')
-rw-r--r--test/unit/issue_nested_set_test.rb34
1 files changed, 33 insertions, 1 deletions
diff --git a/test/unit/issue_nested_set_test.rb b/test/unit/issue_nested_set_test.rb
index df9adbe38..cf61cfdea 100644
--- a/test/unit/issue_nested_set_test.rb
+++ b/test/unit/issue_nested_set_test.rb
@@ -202,7 +202,19 @@ class IssueNestedSetTest < ActiveSupport::TestCase
issue2 = create_issue!
issue3 = create_issue!(:parent_issue_id => issue2.id)
issue4 = create_issue!(:parent_issue_id => issue1.id)
- issue2.reload.destroy
+
+ issue3.init_journal(User.find(2))
+ issue3.subject = 'child with journal'
+ issue3.save!
+
+ assert_difference 'Issue.count', -2 do
+ assert_difference 'Journal.count', -1 do
+ assert_difference 'JournalDetail.count', -1 do
+ Issue.find(issue2.id).destroy
+ end
+ end
+ end
+
issue1.reload
issue4.reload
assert !Issue.exists?(issue2.id)
@@ -211,6 +223,26 @@ class IssueNestedSetTest < ActiveSupport::TestCase
assert_equal [issue1.id, 2, 3], [issue4.root_id, issue4.lft, issue4.rgt]
end
+ def test_destroy_child_issue_with_children
+ root = Issue.create!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'root')
+ child = Issue.create!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => root.id)
+ leaf = Issue.create!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'leaf', :parent_issue_id => child.id)
+ leaf.init_journal(User.find(2))
+ leaf.subject = 'leaf with journal'
+ leaf.save!
+
+ assert_difference 'Issue.count', -2 do
+ assert_difference 'Journal.count', -1 do
+ assert_difference 'JournalDetail.count', -1 do
+ Issue.find(child.id).destroy
+ end
+ end
+ end
+
+ root = Issue.find(root.id)
+ assert root.leaf?, "Root issue is not a leaf (lft: #{root.lft}, rgt: #{root.rgt})"
+ end
+
def test_parent_priority_should_be_the_highest_child_priority
parent = create_issue!(:priority => IssuePriority.find_by_name('Normal'))
# Create children