mirror of
https://github.com/redmine/redmine.git
synced 2026-07-13 10:13:04 +02:00
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:
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user