@@ -223,6 +223,20 class IssueNestedSetTest < ActiveSupport::TestCase | |||
|
223 | 223 | assert_equal [issue1.id, 1, 4], [issue1.root_id, issue1.lft, issue1.rgt] |
|
224 | 224 | assert_equal [issue1.id, 2, 3], [issue4.root_id, issue4.lft, issue4.rgt] |
|
225 | 225 | end |
|
226 | ||
|
227 | def test_destroy_child_should_update_parent | |
|
228 | issue = create_issue! | |
|
229 | child1 = create_issue!(:parent_issue_id => issue.id) | |
|
230 | child2 = create_issue!(:parent_issue_id => issue.id) | |
|
231 | ||
|
232 | issue.reload | |
|
233 | assert_equal [issue.id, 1, 6], [issue.root_id, issue.lft, issue.rgt] | |
|
234 | ||
|
235 | child2.reload.destroy | |
|
236 | ||
|
237 | issue.reload | |
|
238 | assert_equal [issue.id, 1, 4], [issue.root_id, issue.lft, issue.rgt] | |
|
239 | end | |
|
226 | 240 | |
|
227 | 241 | def test_destroy_parent_issue_updated_during_children_destroy |
|
228 | 242 | parent = create_issue! |
@@ -444,7 +444,7 module CollectiveIdea #:nodoc: | |||
|
444 | 444 | # Prunes a branch off of the tree, shifting all of the elements on the right |
|
445 | 445 | # back to the left so the counts still work. |
|
446 | 446 | def prune_from_tree |
|
447 |
return if right.nil? || left.nil? || |
|
|
447 | return if right.nil? || left.nil? || !self.class.exists?(id) | |
|
448 | 448 | |
|
449 | 449 | self.class.base_class.transaction do |
|
450 | 450 | reload_nested_set |
General Comments 0
You need to be logged in to leave comments.
Login now