Skip to content

Commit

Permalink
Regression: #children should be ordered by left column
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeepers committed Sep 8, 2009
1 parent 6a772b3 commit 5aea347
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/awesome_nested_set.rb
Expand Up @@ -63,7 +63,7 @@ def acts_as_nested_set(options = {})
belongs_to :parent, :class_name => self.base_class.class_name,
:foreign_key => parent_column_name
has_many :children, :class_name => self.base_class.class_name,
:foreign_key => parent_column_name
:foreign_key => parent_column_name, :order => quoted_left_column_name

attr_accessor :skip_before_destroy

Expand Down
7 changes: 7 additions & 0 deletions test/awesome_nested_set_test.rb
Expand Up @@ -195,6 +195,13 @@ def test_children
category.children.each {|c| assert_equal category.id, c.parent_id }
end

def test_order_of_children
categories(:child_2).move_left
assert_equal categories(:child_2), categories(:top_level).children[0]
assert_equal categories(:child_1), categories(:top_level).children[1]
assert_equal categories(:child_3), categories(:top_level).children[2]
end

def test_is_or_is_ancestor_of?
assert categories(:top_level).is_or_is_ancestor_of?(categories(:child_1))
assert categories(:top_level).is_or_is_ancestor_of?(categories(:child_2_1))
Expand Down

0 comments on commit 5aea347

Please sign in to comment.