From 419b195019a276513d1d58a0ed7d7a18c58425be Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 22 Jan 2011 11:46:15 +0000 Subject: 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 --- test/unit/issue_nested_set_test.rb | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'test/unit/issue_nested_set_test.rb') 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 -- cgit v1.2.3