]> source.dussan.org Git - redmine.git/commitdiff
call Project#set_or_update_position_under in Project.rebuild_tree! (#12431)
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 21 Jan 2014 06:29:48 +0000 (06:29 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 21 Jan 2014 06:29:48 +0000 (06:29 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@12683 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/project.rb
test/unit/project_nested_set_test.rb

index 798e64f691b1b332c3bac5c9689e346c30531d38..e031da9e73c14f47f55dd69053c218db0f519262 100644 (file)
@@ -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
index 6048cd23d3a90c1eb5c9bb61694d439218ddc870..7312d9bd6eb1ce2c54d7d1a69e46cb31d788db55 100644 (file)
@@ -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