class TreeTest
Public Instance Methods
setup()
click to toggle source
# File lib/plugins/acts_as_tree/test/acts_as_tree_test.rb, line 61 def setup setup_db @root1 = TreeMixin.create! @root_child1 = TreeMixin.create! :parent_id => @root1.id @child1_child = TreeMixin.create! :parent_id => @root_child1.id @root_child2 = TreeMixin.create! :parent_id => @root1.id @root2 = TreeMixin.create! @root3 = TreeMixin.create! end
teardown()
click to toggle source
# File lib/plugins/acts_as_tree/test/acts_as_tree_test.rb, line 71 def teardown teardown_db end
test_ancestors()
click to toggle source
# File lib/plugins/acts_as_tree/test/acts_as_tree_test.rb, line 110 def test_ancestors assert_equal [], @root1.ancestors assert_equal [@root1], @root_child1.ancestors assert_equal [@root_child1, @root1], @child1_child.ancestors assert_equal [@root1], @root_child2.ancestors assert_equal [], @root2.ancestors assert_equal [], @root3.ancestors end
test_children()
click to toggle source
# File lib/plugins/acts_as_tree/test/acts_as_tree_test.rb, line 75 def test_children assert_equal @root1.children, [@root_child1, @root_child2] assert_equal @root_child1.children, [@child1_child] assert_equal @child1_child.children, [] assert_equal @root_child2.children, [] end
test_delete()
click to toggle source
# File lib/plugins/acts_as_tree/test/acts_as_tree_test.rb, line 88 def test_delete assert_equal 6, TreeMixin.count @root1.destroy assert_equal 2, TreeMixin.count @root2.destroy @root3.destroy assert_equal 0, TreeMixin.count end
test_insert()
click to toggle source
# File lib/plugins/acts_as_tree/test/acts_as_tree_test.rb, line 97 def test_insert @extra = @root1.children.create assert @extra assert_equal @extra.parent, @root1 assert_equal 3, @root1.children.size assert @root1.children.include?(@extra) assert @root1.children.include?(@root_child1) assert @root1.children.include?(@root_child2) end
test_parent()
click to toggle source
# File lib/plugins/acts_as_tree/test/acts_as_tree_test.rb, line 82 def test_parent assert_equal @root_child1.parent, @root1 assert_equal @root_child1.parent, @root_child2.parent assert_nil @root1.parent end
test_root()
click to toggle source
# File lib/plugins/acts_as_tree/test/acts_as_tree_test.rb, line 119 def test_root assert_equal @root1, TreeMixin.root assert_equal @root1, @root1.root assert_equal @root1, @root_child1.root assert_equal @root1, @child1_child.root assert_equal @root1, @root_child2.root assert_equal @root2, @root2.root assert_equal @root3, @root3.root end
test_roots()
click to toggle source
# File lib/plugins/acts_as_tree/test/acts_as_tree_test.rb, line 129 def test_roots assert_equal [@root1, @root2, @root3], TreeMixin.roots end
test_self_and_siblings()
click to toggle source
# File lib/plugins/acts_as_tree/test/acts_as_tree_test.rb, line 142 def test_self_and_siblings assert_equal [@root1, @root2, @root3], @root1.self_and_siblings assert_equal [@root_child1, @root_child2], @root_child1.self_and_siblings assert_equal [@child1_child], @child1_child.self_and_siblings assert_equal [@root_child1, @root_child2], @root_child2.self_and_siblings assert_equal [@root1, @root2, @root3], @root2.self_and_siblings assert_equal [@root1, @root2, @root3], @root3.self_and_siblings end
test_siblings()
click to toggle source
# File lib/plugins/acts_as_tree/test/acts_as_tree_test.rb, line 133 def test_siblings assert_equal [@root2, @root3], @root1.siblings assert_equal [@root_child2], @root_child1.siblings assert_equal [], @child1_child.siblings assert_equal [@root_child1], @root_child2.siblings assert_equal [@root1, @root3], @root2.siblings assert_equal [@root1, @root2], @root3.siblings end