aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-01-01 01:48:12 +0100
committerJosé Valim <jose.valim@gmail.com>2010-01-01 01:48:12 +0100
commit50fbb7405665ba1c2b7c6f23574053a4764cef7f (patch)
tree14ae29163aad9a60288629188e973a195cdc06eb /activesupport/test
parentea41a757aab86206278b99deb86e93a760833819 (diff)
downloadrails-50fbb7405665ba1c2b7c6f23574053a4764cef7f.tar.gz
rails-50fbb7405665ba1c2b7c6f23574053a4764cef7f.tar.bz2
rails-50fbb7405665ba1c2b7c6f23574053a4764cef7f.zip
Fix inheritance issue with new callbacks.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/callback_inheritance_test.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/activesupport/test/callback_inheritance_test.rb b/activesupport/test/callback_inheritance_test.rb
index 18721eab19..2e978f01be 100644
--- a/activesupport/test/callback_inheritance_test.rb
+++ b/activesupport/test/callback_inheritance_test.rb
@@ -56,6 +56,31 @@ class Child < GrandParent
end
end
+class EmptyParent
+ include ActiveSupport::Callbacks
+
+ def performed?
+ @performed ||= false
+ end
+
+ define_callbacks :dispatch
+
+ def perform!
+ @performed = true
+ end
+
+ def dispatch
+ _run_dispatch_callbacks
+ self
+ end
+end
+
+class EmptyChild < EmptyParent
+ set_callback :dispatch, :before, :do_nothing
+
+ def do_nothing
+ end
+end
class BasicCallbacksTest < Test::Unit::TestCase
def setup
@@ -113,3 +138,13 @@ class InheritedCallbacksTest2 < Test::Unit::TestCase
assert_equal %w(before1 before2 update after2 after1), @update2.log
end
end
+
+class DynamicInheritedCallbacks < Test::Unit::TestCase
+ def test_callbacks_looks_to_the_superclass_before_running
+ child = EmptyChild.new.dispatch
+ assert !child.performed?
+ EmptyParent.set_callback :dispatch, :before, :perform!
+ child = EmptyChild.new.dispatch
+ assert child.performed?
+ end
+end