diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-12-31 18:24:45 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-12-31 18:24:45 -0800 |
commit | 9790f0eda56b9337f58646e0ce552ae1b5c78316 (patch) | |
tree | 904d61693ffebc943b6269ecf31df6caeab8f47f /activesupport/test | |
parent | 6ce562c9fff4084e185c3c57cc609d3bf5ac0cfc (diff) | |
parent | 8c5fe60ec82986ab4aa337a69c2ab753f518976d (diff) | |
download | rails-9790f0eda56b9337f58646e0ce552ae1b5c78316.tar.gz rails-9790f0eda56b9337f58646e0ce552ae1b5c78316.tar.bz2 rails-9790f0eda56b9337f58646e0ce552ae1b5c78316.zip |
Merge commit 'josevalim/inheritance'
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/callback_inheritance_test.rb | 35 |
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 |