Skip to content

retrieving ancestors for a root node doesn't work #4

@dhoss

Description

@dhoss

node.ancestors.count should return 0 if the parent_id is null.

Here's an example of what we get now:

it "has the correct tree after subchildren are added" do tree = Node.roots.first.self_and_descendents tree.each do |node| if node.parent_id.nil? expect(node.ancestors.count).to eq(0) end end

Gives us:

Failures:

  1) Treeify Modifying the tree has the correct tree after subchildren are added
     Failure/Error: expect(node.ancestors.count).to eq(0)

        expected: 0
        got: 53

   (compared using ==)
 # ./spec/treeify_spec.rb:104:in `block (4 levels) in <top (required)>'
 # ./spec/treeify_spec.rb:102:in `each'
 # ./spec/treeify_spec.rb:102:in `block (3 levels) in <top (required)>'

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions