diff options
author | Aaron Pfeifer <aaron.pfeifer@gmail.com> | 2011-03-07 21:07:46 +0800 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-03-08 15:01:05 +0800 |
commit | df615f127ece4f712448ae5bd3e993ec378d8f7a (patch) | |
tree | 0aed9c73c7ad0f871db418f5ad91efecc3196c7a /activesupport/test | |
parent | 1408b942d9c2c131a1cdcab97f49d74ce84dae38 (diff) | |
download | rails-df615f127ece4f712448ae5bd3e993ec378d8f7a.tar.gz rails-df615f127ece4f712448ae5bd3e993ec378d8f7a.tar.bz2 rails-df615f127ece4f712448ae5bd3e993ec378d8f7a.zip |
Allow access to a callback event's return result from around callbacks
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/callbacks_test.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/activesupport/test/callbacks_test.rb b/activesupport/test/callbacks_test.rb index cff914f4ae..0b4cc4ac69 100644 --- a/activesupport/test/callbacks_test.rb +++ b/activesupport/test/callbacks_test.rb @@ -299,6 +299,22 @@ module CallbacksTest end end end + + class AroundPersonResult < MySuper + attr_reader :result + + set_callback :save, :around, :tweedle_dum + + def tweedle_dum + @result = yield + end + + def save + run_callbacks :save do + :running + end + end + end class HyphenatedCallbacks include ActiveSupport::Callbacks @@ -338,6 +354,14 @@ module CallbacksTest ], around.history end end + + class AroundCallbackResultTest < Test::Unit::TestCase + def test_save_around + around = AroundPersonResult.new + around.save + assert_equal :running, around.result + end + end class SkipCallbacksTest < Test::Unit::TestCase def test_skip_person |