Skip to content

Looks it can not work will #23

@huacnlee

Description

@huacnlee

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
end
context "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
end

It can not pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions