提交 b2681cca 编写于 作者: J Jeremy Kemper

acts_as_nested_set: direct_children is sorted correctly. Closes #4761.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6903 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 b7d2dae6
*SVN*
* acts_as_nested_set: direct_children is sorted correctly. #4761 [Josh Peek, rails@33lc0.net]
* Raise an exception if both attr_protected and attr_accessible are declared. #8507 [stellsmi]
* SQLite, MySQL, PostgreSQL, Oracle: quote column names in column migration SQL statements. #8466 [marclove, lorenjohnson]
......
......@@ -190,7 +190,7 @@ def all_children
# Returns a set of only this entry's immediate children
def direct_children
self.class.base_class.find(:all, :conditions => "#{scope_condition} and #{parent_column} = #{self.id}")
self.class.base_class.find(:all, :conditions => "#{scope_condition} and #{parent_column} = #{self.id}", :order => left_col_name)
end
# Prunes a branch off of the tree, shifting all of the elements on the right
......
......@@ -101,10 +101,10 @@ sti_set_<%= sti[0] %>:
[4002, 4001, 2, 7],
[4003, 4002, 3, 4],
[4004, 4002, 5, 6],
[4005, 4001, 8, 13],
[4005, 4001, 14, 13],
[4006, 4005, 9, 10],
[4007, 4005, 11, 12],
[4008, 4001, 14, 19],
[4008, 4001, 8, 19],
[4009, 4008, 15, 16],
[4010, 4008, 17, 18]].each do |set| %>
tree_<%= set[0] %>:
......
......@@ -116,12 +116,13 @@ def test_snipping_tree
# Make sure we have the right one
assert_equal( 3, big_tree.direct_children.length )
assert_equal( 10, big_tree.full_set.length )
assert_equal [4002, 4008, 4005], big_tree.direct_children.map(&:id)
NestedSetWithStringScope.find( 4005 ).destroy
big_tree = NestedSetWithStringScope.find( 4001 )
assert_equal( 7, big_tree.full_set.length )
assert_equal( 9, big_tree.full_set.length )
assert_equal( 2, big_tree.direct_children.length )
assert_equal( 1, NestedSetWithStringScope.find(4001).lft )
......@@ -132,12 +133,12 @@ def test_snipping_tree
assert_equal( 6, NestedSetWithStringScope.find(4004).rgt )
assert_equal( 7, NestedSetWithStringScope.find(4002).rgt )
assert_equal( 8, NestedSetWithStringScope.find(4008).lft )
assert_equal( 9, NestedSetWithStringScope.find(4009).lft )
assert_equal(10, NestedSetWithStringScope.find(4009).rgt )
assert_equal(11, NestedSetWithStringScope.find(4010).lft )
assert_equal(12, NestedSetWithStringScope.find(4010).rgt )
assert_equal(13, NestedSetWithStringScope.find(4008).rgt )
assert_equal(14, NestedSetWithStringScope.find(4001).rgt )
assert_equal(15, NestedSetWithStringScope.find(4009).lft )
assert_equal(16, NestedSetWithStringScope.find(4009).rgt )
assert_equal(17, NestedSetWithStringScope.find(4010).lft )
assert_equal(18, NestedSetWithStringScope.find(4010).rgt )
assert_equal(19, NestedSetWithStringScope.find(4008).rgt )
assert_equal(20, NestedSetWithStringScope.find(4001).rgt )
end
def test_deleting_root
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册