mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
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:
parent
d19a0b70e0
commit
00d1b230e0
@ -222,6 +222,20 @@ class IssueNestedSetTest < ActiveSupport::TestCase
|
|||||||
assert_equal [issue1.id, 1, 4], [issue1.root_id, issue1.lft, issue1.rgt]
|
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]
|
assert_equal [issue1.id, 2, 3], [issue4.root_id, issue4.lft, issue4.rgt]
|
||||||
end
|
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
|
def test_destroy_parent_issue_updated_during_children_destroy
|
||||||
parent = create_issue!
|
parent = create_issue!
|
||||||
|
|||||||
@ -162,9 +162,10 @@ module CollectiveIdea #:nodoc:
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Rebuilds the left & rights if unset or invalid. Also very useful for converting from acts_as_tree.
|
# 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.
|
# 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|}
|
scope = lambda{|node|}
|
||||||
if acts_as_nested_set_options[:scope]
|
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
|
# Prunes a branch off of the tree, shifting all of the elements on the right
|
||||||
# back to the left so the counts still work.
|
# back to the left so the counts still work.
|
||||||
def prune_from_tree
|
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
|
self.class.base_class.transaction do
|
||||||
reload_nested_set
|
reload_nested_set
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user