transaction do
update_all "lft = NULL, rgt = NULL"
rebuild!(false)
+ all.each { |p| p.set_or_update_position_under(p.parent) }
end
end
set_or_update_position_under(parent)
end
+ public
+
# Inserts/moves the project so that target's children or root projects stay alphabetically sorted
def set_or_update_position_under(target_parent)
parent_was = parent
def test_rebuild_should_build_valid_tree
Project.update_all "lft = NULL, rgt = NULL"
- Project.rebuild!
+ Project.rebuild_tree!
assert_valid_nested_set
end