]> source.dussan.org Git - redmine.git/commitdiff
Fixed: Deleting a subtasks doesn't update parent's rgt & lft values, introduced by...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 15 Nov 2011 19:55:21 +0000 (19:55 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 15 Nov 2011 19:55:21 +0000 (19:55 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7814 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/unit/issue_nested_set_test.rb
vendor/plugins/awesome_nested_set/lib/awesome_nested_set.rb

index d7be363444ef57fcddd3e0556b2a7c4611c9a551..8d98ccf06cfe0aa8552c11bfdb63602a3cc8999f 100644 (file)
@@ -223,6 +223,20 @@ class IssueNestedSetTest < ActiveSupport::TestCase
     assert_equal [issue1.id, 1, 4], [issue1.root_id, issue1.lft, issue1.rgt]
     assert_equal [issue1.id, 2, 3], [issue4.root_id, issue4.lft, issue4.rgt]
   end
+  
+  def test_destroy_child_should_update_parent
+    issue = create_issue!
+    child1 = create_issue!(:parent_issue_id => issue.id)
+    child2 = create_issue!(:parent_issue_id => issue.id)
+    
+    issue.reload
+    assert_equal [issue.id, 1, 6], [issue.root_id, issue.lft, issue.rgt]
+    
+    child2.reload.destroy
+    
+    issue.reload
+    assert_equal [issue.id, 1, 4], [issue.root_id, issue.lft, issue.rgt]
+  end
 
   def test_destroy_parent_issue_updated_during_children_destroy
     parent = create_issue!
index fcf00b3c3dcc9a22105aeb09ed31af1d67b2120a..e50e2a6719ac4f663147a0d547087b02b84688fc 100644 (file)
@@ -444,7 +444,7 @@ module CollectiveIdea #:nodoc:
         # Prunes a branch off of the tree, shifting all of the elements on the right
         # back to the left so the counts still work.
         def prune_from_tree
-          return if right.nil? || left.nil? || leaf? || !self.class.exists?(id)
+          return if right.nil? || left.nil? || !self.class.exists?(id)
 
           self.class.base_class.transaction do
             reload_nested_set