-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
There have wrong lft, rgt value.
And then, I clone lastest source from thinkwell/mongoid_nested_set, and try to write the test case like this graph:
class Comment
include Mongoid::Document
acts_as_nested_set :scope => :commentable
field :body
belongs_to :commentable, :polymorphic => true
endcontext "test with polymorphic model" do
it "should get right tree" do
@node = Node.create(:name => 'Foo', :root_id => 0)
food = Comment.create(:commentable => @node, :body => "Food")
fruit = food.children.create(:commentable => @node, :body => "Fruit")
red = fruit.children.create(:commentable => @node, :body => "Red")
cherry = red.children.create(:commentable => @node, :body => "Cherry")
yellow = fruit.children.create(:commentable => @node, :body => "Yellow")
banana = yellow.children.create(:commentable => @node, :body => "Banana")
meat = food.children.create(:commentable => @node, :body => "Meat")
beef = meat.children.create(:commentable => @node, :body => "Beef")
pork = meat.children.create(:commentable => @node, :body => "Pork")
[food.lft,food.rgt].should == [1,18]
[fruit.lft,fruit.rgt].should == [2,11]
[red.lft,red.rgt].should == [3,6]
[cherry.lft,cherry.rgt].should == [4,5]
[yellow.lft,yellow.rgt].should == [7,10]
[banana.lft,banana.rgt].should == [8,9]
[meat.lft,meat.rgt].should == [12,17]
[beef.lft,beef.rgt].should == [13,14]
[pork.lft,pork.rgt].should == [15,16]
end
endIt can not pass.
Metadata
Metadata
Assignees
Labels
No labels
