##// END OF EJS Templates
Fixed that Project.rebuild! sorts projects by id instead of name (#12431)....
Jean-Philippe Lang -
r10639:13f5301c097f
parent child
Show More
@@ -186,7 +186,7 module CollectiveIdea #:nodoc:
186 end
186 end
187
187
188 # Find root node(s)
188 # Find root node(s)
189 root_nodes = where("#{quoted_parent_column_name} IS NULL").order("#{quoted_left_column_name}, #{quoted_right_column_name}, id").each do |root_node|
189 root_nodes = where("#{quoted_parent_column_name} IS NULL").order(acts_as_nested_set_options[:order]).each do |root_node|
190 # setup index for this scope
190 # setup index for this scope
191 indices[scope.call(root_node)] ||= 0
191 indices[scope.call(root_node)] ||= 0
192 set_left_and_rights.call(root_node)
192 set_left_and_rights.call(root_node)
@@ -47,6 +47,13 class ProjectNestedSetTest < ActiveSupport::TestCase
47 assert_valid_nested_set
47 assert_valid_nested_set
48 end
48 end
49
49
50 def test_rebuild_should_build_valid_tree
51 Project.update_all "lft = NULL, rgt = NULL"
52
53 Project.rebuild!
54 assert_valid_nested_set
55 end
56
50 def test_moving_a_child_to_a_different_parent_should_keep_valid_tree
57 def test_moving_a_child_to_a_different_parent_should_keep_valid_tree
51 assert_no_difference 'Project.count' do
58 assert_no_difference 'Project.count' do
52 Project.find_by_name('B1').set_parent!(Project.find_by_name('A2'))
59 Project.find_by_name('B1').set_parent!(Project.find_by_name('A2'))
General Comments 0
You need to be logged in to leave comments. Login now