Skip to content
This repository
Browse code

added test cases

  • Loading branch information...
commit de34c814dab66ec315e0efd6e138e1aeb0af6303 1 parent aec25d1
unknown authored

Showing 1 changed file with 16 additions and 0 deletions. Show diff stats Hide diff stats

  1. +16 0 test/has_ancestry_test.rb
16 test/has_ancestry_test.rb
... ... @@ -1,6 +1,7 @@
1 1 require File.join(File.expand_path(File.dirname(__FILE__)), "environment")
2 2
3 3 class HasAncestryTreeTest < ActiveSupport::TestCase
  4 +
4 5 def test_default_ancestry_column
5 6 AncestryTestDatabase.with_model do |model|
6 7 assert_equal :ancestry, model.ancestry_column
@@ -322,6 +323,21 @@ def test_orphan_restrict_strategy
322 323 end
323 324 end
324 325 end
  326 +
  327 + def test_orphan_parentify_strategy
  328 + AncestryTestDatabase.with_model do |model|
  329 + model.orphan_strategy = :parentify
  330 + n1 = model.create!
  331 + n2 = model.create!(:parent => n1)
  332 + n3 = model.create!(:parent => n2)
  333 + n4 = model.create!(:parent => n2)
  334 + n5 = model.create!(:parent => n4)
  335 + # delete a node with desecendants
  336 + n2.destroy
  337 + assert_equal(model.find(3).parent,n1, "orphan's not parentified as excepted" )
  338 + assert_equal(model.find(5).ancestor_ids,[n1.id,n4.id], "ancestry integrity not maintained")
  339 + end
  340 + end
325 341
326 342 def test_integrity_checking
327 343 AncestryTestDatabase.with_model :width => 3, :depth => 3 do |model, roots|

0 comments on commit de34c81

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