Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix tests

  • Loading branch information...
commit 578fc8d1eae2dc37b6f44bd5919982c9aa3b77a0 1 parent b024682
@chipiga chipiga authored
Showing with 35 additions and 35 deletions.
  1. +35 −35 test/has_ancestry_test.rb
View
70 test/has_ancestry_test.rb
@@ -108,7 +108,7 @@ def test_tree_navigation
roots.each do |lvl0_node, lvl0_children|
# Ancestors assertions
assert_equal [], lvl0_node.ancestor_ids
- assert_equal [], lvl0_node.ancestors
+ assert_equal [], lvl0_node.ancestors.all
assert_equal [lvl0_node.id], lvl0_node.path_ids
assert_equal [lvl0_node], lvl0_node.path
assert_equal 0, lvl0_node.depth
@@ -121,12 +121,12 @@ def test_tree_navigation
assert lvl0_node.is_root?
# Children assertions
assert_equal lvl0_children.map(&:first).map(&:id), lvl0_node.child_ids
- assert_equal lvl0_children.map(&:first), lvl0_node.children
+ assert_equal lvl0_children.map(&:first), lvl0_node.children.all
assert lvl0_node.has_children?
assert !lvl0_node.is_childless?
# Siblings assertions
assert_equal roots.map(&:first).map(&:id), lvl0_node.sibling_ids
- assert_equal roots.map(&:first), lvl0_node.siblings
+ assert_equal roots.map(&:first), lvl0_node.siblings.all
assert lvl0_node.has_siblings?
assert !lvl0_node.is_only_child?
# Descendants assertions
@@ -134,15 +134,15 @@ def test_tree_navigation
node.ancestor_ids.include? lvl0_node.id
end
assert_equal descendants.map(&:id), lvl0_node.descendant_ids
- assert_equal descendants, lvl0_node.descendants
- assert_equal [lvl0_node] + descendants, lvl0_node.subtree
+ assert_equal descendants, lvl0_node.descendants.all
+ assert_equal [lvl0_node] + descendants, lvl0_node.subtree.all
lvl0_children.each do |lvl1_node, lvl1_children|
# Ancestors assertions
assert_equal [lvl0_node.id], lvl1_node.ancestor_ids
- assert_equal [lvl0_node], lvl1_node.ancestors
+ assert_equal [lvl0_node], lvl1_node.ancestors.all
assert_equal [lvl0_node.id, lvl1_node.id], lvl1_node.path_ids
- assert_equal [lvl0_node, lvl1_node], lvl1_node.path
+ assert_equal [lvl0_node, lvl1_node], lvl1_node.path.all
assert_equal 1, lvl1_node.depth
# Parent assertions
assert_equal lvl0_node.id, lvl1_node.parent_id
@@ -153,12 +153,12 @@ def test_tree_navigation
assert !lvl1_node.is_root?
# Children assertions
assert_equal lvl1_children.map(&:first).map(&:id), lvl1_node.child_ids
- assert_equal lvl1_children.map(&:first), lvl1_node.children
+ assert_equal lvl1_children.map(&:first), lvl1_node.children.all
assert lvl1_node.has_children?
assert !lvl1_node.is_childless?
# Siblings assertions
assert_equal lvl0_children.map(&:first).map(&:id), lvl1_node.sibling_ids
- assert_equal lvl0_children.map(&:first), lvl1_node.siblings
+ assert_equal lvl0_children.map(&:first), lvl1_node.siblings.all
assert lvl1_node.has_siblings?
assert !lvl1_node.is_only_child?
# Descendants assertions
@@ -166,15 +166,15 @@ def test_tree_navigation
node.ancestor_ids.include? lvl1_node.id
end
assert_equal descendants.map(&:id), lvl1_node.descendant_ids
- assert_equal descendants, lvl1_node.descendants
- assert_equal [lvl1_node] + descendants, lvl1_node.subtree
+ assert_equal descendants, lvl1_node.descendants.all
+ assert_equal [lvl1_node] + descendants, lvl1_node.subtree.all
lvl1_children.each do |lvl2_node, lvl2_children|
# Ancestors assertions
assert_equal [lvl0_node.id, lvl1_node.id], lvl2_node.ancestor_ids
- assert_equal [lvl0_node, lvl1_node], lvl2_node.ancestors
+ assert_equal [lvl0_node, lvl1_node], lvl2_node.ancestors.all
assert_equal [lvl0_node.id, lvl1_node.id, lvl2_node.id], lvl2_node.path_ids
- assert_equal [lvl0_node, lvl1_node, lvl2_node], lvl2_node.path
+ assert_equal [lvl0_node, lvl1_node, lvl2_node], lvl2_node.path.all
assert_equal 2, lvl2_node.depth
# Parent assertions
assert_equal lvl1_node.id, lvl2_node.parent_id
@@ -185,12 +185,12 @@ def test_tree_navigation
assert !lvl2_node.is_root?
# Children assertions
assert_equal [], lvl2_node.child_ids
- assert_equal [], lvl2_node.children
+ assert_equal [], lvl2_node.children.all
assert !lvl2_node.has_children?
assert lvl2_node.is_childless?
# Siblings assertions
assert_equal lvl1_children.map(&:first).map(&:id), lvl2_node.sibling_ids
- assert_equal lvl1_children.map(&:first), lvl2_node.siblings
+ assert_equal lvl1_children.map(&:first), lvl2_node.siblings.all
assert lvl2_node.has_siblings?
assert !lvl2_node.is_only_child?
# Descendants assertions
@@ -198,8 +198,8 @@ def test_tree_navigation
node.ancestor_ids.include? lvl2_node.id
end
assert_equal descendants.map(&:id), lvl2_node.descendant_ids
- assert_equal descendants, lvl2_node.descendants
- assert_equal [lvl2_node] + descendants, lvl2_node.subtree
+ assert_equal descendants, lvl2_node.descendants.all
+ assert_equal [lvl2_node] + descendants, lvl2_node.subtree.all
end
end
end
@@ -213,32 +213,32 @@ def test_named_scopes
TestNode.all.each do |test_node|
# Assertions for ancestors_of named scope
- assert_equal test_node.ancestors, TestNode.ancestors_of(test_node)
- assert_equal test_node.ancestors, TestNode.ancestors_of(test_node.id)
+ assert_equal test_node.ancestors.all, TestNode.ancestors_of(test_node).all
+ assert_equal test_node.ancestors.all, TestNode.ancestors_of(test_node.id).all
# Assertions for children_of named scope
- assert_equal test_node.children, TestNode.children_of(test_node)
- assert_equal test_node.children, TestNode.children_of(test_node.id)
+ assert_equal test_node.children.all, TestNode.children_of(test_node).all
+ assert_equal test_node.children.all, TestNode.children_of(test_node.id).all
# Assertions for descendants_of named scope
- assert_equal test_node.descendants, TestNode.descendants_of(test_node)
- assert_equal test_node.descendants, TestNode.descendants_of(test_node.id)
+ assert_equal test_node.descendants.all, TestNode.descendants_of(test_node).all
+ assert_equal test_node.descendants.all, TestNode.descendants_of(test_node.id).all
# Assertions for subtree_of named scope
- assert_equal test_node.subtree, TestNode.subtree_of(test_node)
- assert_equal test_node.subtree, TestNode.subtree_of(test_node.id)
+ assert_equal test_node.subtree.all, TestNode.subtree_of(test_node).all
+ assert_equal test_node.subtree.all, TestNode.subtree_of(test_node.id).all
# Assertions for siblings_of named scope
- assert_equal test_node.siblings, TestNode.siblings_of(test_node)
- assert_equal test_node.siblings, TestNode.siblings_of(test_node.id)
+ assert_equal test_node.siblings.all, TestNode.siblings_of(test_node).all
+ assert_equal test_node.siblings.all, TestNode.siblings_of(test_node.id).all
end
end
def test_ancestroy_column_validation
node = TestNode.create
['3', '10/2', '1/4/30', nil].each do |value|
- node.write_attribute TestNode.ancestry_column, value
- node.valid?; assert !node.errors.invalid?(TestNode.ancestry_column)
+ node[TestNode.ancestry_column] = value
+ node.valid?; assert !node.errors[TestNode.ancestry_column].any?
end
['1/3/', '/2/3', 'a', 'a/b', '-34', '/54'].each do |value|
- node.write_attribute TestNode.ancestry_column, value
- node.valid?; assert node.errors.invalid?(TestNode.ancestry_column)
+ node[TestNode.ancestry_column] = value
+ node.valid?; assert node.errors[TestNode.ancestry_column].any?
end
end
@@ -576,10 +576,10 @@ def test_sti_support
node4 = TestNodeSub2.create! :parent => node3
node5 = TestNodeSub1.create! :parent => node4
- assert_equal [node2, node3, node4, node5], node1.descendants
- assert_equal [node1, node2, node3, node4, node5], node1.subtree
- assert_equal [node1, node2, node3, node4], node5.ancestors
- assert_equal [node1, node2, node3, node4, node5], node5.path
+ assert_equal [node2, node3, node4, node5], node1.descendants.all
+ assert_equal [node1, node2, node3, node4, node5], node1.subtree.all
+ assert_equal [node1, node2, node3, node4], node5.ancestors.all
+ assert_equal [node1, node2, node3, node4, node5], node5.path.all
end
def test_arrange_order_option

0 comments on commit 578fc8d

Please sign in to comment.
Something went wrong with that request. Please try again.