Merged r7814 from trunk (#9577).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.2-stable@8117 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2011-12-07 21:54:05 +00:00
parent d19a0b70e0
commit 00d1b230e0
2 changed files with 18 additions and 3 deletions
@@ -162,9 +162,10 @@ module CollectiveIdea #:nodoc:
end
# Rebuilds the left & rights if unset or invalid. Also very useful for converting from acts_as_tree.
def rebuild!
def rebuild!(force=false)
# Don't rebuild a valid tree.
return true if valid?
# valid? doesn't strictly validate the tree
return true if !force && valid?
scope = lambda{|node|}
if acts_as_nested_set_options[:scope]
@@ -444,7 +445,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