Skip to content
Browse files

Test to cover ticket: #44 (comment)

  • Loading branch information...
1 parent 522d663 commit e552e100b66164e425a62042bef617447a1a0085 @cheerfulstoic cheerfulstoic committed with Stefan Henzen
Showing with 17 additions and 0 deletions.
  1. +17 −0 test/has_ancestry_test.rb
View
17 test/has_ancestry_test.rb
@@ -51,6 +51,23 @@ def test_setting_invalid_orphan_strategy
end
end
+ def test_scoping_in_callbacks
+ AncestryTestDatabase.with_model do |model|
+ model.instance_eval do
+ after_create :after_create_callback
+ end
+ model.class_eval do
+ def after_create_callback
+ # We don't want to be in the #children scope here when creating the child
+ self.parent
+ end
+ end
+
+ parent = model.create
+ assert child = parent.children.create
+ end
+ end
+
def test_setup_test_nodes
AncestryTestDatabase.with_model :depth => 3, :width => 3 do |model, roots|
assert_equal Array, roots.class

0 comments on commit e552e10

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