We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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:
thinkwell/mongoid_nested_set
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.
The text was updated successfully, but these errors were encountered:
I have looped the all of comments to see the datas in DB
Comment.each do |c| tl = " "*c.depth nl = "#{c.body}" print tl, nl print "lft: #{c.lft}, rgt: #{c.rgt} ".rjust(80 - tl.length - nl.length) puts "" end
Got this result:
Food lft: 1, rgt: 18 Fruit lft: 2, rgt: 11 Red lft: 3, rgt: 6 Cherry lft: 4, rgt: 5 Yellow lft: 7, rgt: 10 Banana lft: 8, rgt: 9 Meat lft: 12, rgt: 17 Beef lft: 13, rgt: 14 Pork lft: 15, rgt: 16
Look like the lft,rgt values in database is right.
lft
rgt
Sorry, something went wrong.
No branches or pull requests
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:It can not pass.
The text was updated successfully, but these errors were encountered: