Adds :order option to acts_as_nested_tree so that children are sorted alphabetically when the tree is rebuilt.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/work@2156 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2008-12-20 17:58:55 +00:00
parent 01ab34d401
commit efff5dff9b
3 changed files with 20 additions and 3 deletions

View File

@@ -118,6 +118,22 @@ class ProjectTest < Test::Unit::TestCase
assert !(sub.set_parent!(Project.find(3)))
end
def test_rebuild_should_sort_children_alphabetically
ProjectCustomField.delete_all
parent = Project.create!(:name => 'Parent', :identifier => 'parent')
Project.create!(:name => 'Project C', :identifier => 'project-c').move_to_child_of(parent)
Project.create!(:name => 'Project B', :identifier => 'project-b').move_to_child_of(parent)
Project.create!(:name => 'Project D', :identifier => 'project-d').move_to_child_of(parent)
Project.create!(:name => 'Project A', :identifier => 'project-a').move_to_child_of(parent)
Project.update_all("lft = NULL, rgt = NULL")
Project.rebuild!
parent.reload
assert_equal 4, parent.children.size
assert_equal parent.children.sort_by(&:name), parent.children
end
def test_rolled_up_trackers
parent = Project.find(1)
parent.trackers = Tracker.find([1,2])