call Project#set_or_update_position_under in Project.rebuild_tree! (#12431)
git-svn-id: http://svn.redmine.org/redmine/trunk@12683 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
94e3eb2b8b
commit
962ecabc47
|
@ -421,6 +421,7 @@ class Project < ActiveRecord::Base
|
|||
transaction do
|
||||
update_all "lft = NULL, rgt = NULL"
|
||||
rebuild!(false)
|
||||
all.each { |p| p.set_or_update_position_under(p.parent) }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1017,6 +1018,8 @@ class Project < ActiveRecord::Base
|
|||
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
|
||||
|
|
|
@ -50,7 +50,7 @@ class ProjectNestedSetTest < ActiveSupport::TestCase
|
|||
def test_rebuild_should_build_valid_tree
|
||||
Project.update_all "lft = NULL, rgt = NULL"
|
||||
|
||||
Project.rebuild!
|
||||
Project.rebuild_tree!
|
||||
assert_valid_nested_set
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue