diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-12-07 15:29:51 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-12-07 15:29:51 -0500 |
commit | 1b97d41e52e4888681b81f99335d851d434458d1 (patch) | |
tree | ea0a5bd4d06f0e1362fdd193453de725b5605c9d /actionpack | |
parent | 5fb94ec04453d36fee31a227e9a54f1011527a7a (diff) | |
download | rails-1b97d41e52e4888681b81f99335d851d434458d1.tar.gz rails-1b97d41e52e4888681b81f99335d851d434458d1.tar.bz2 rails-1b97d41e52e4888681b81f99335d851d434458d1.zip |
add tests to aliased _filter callbacks
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/test/abstract/callbacks_test.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/actionpack/test/abstract/callbacks_test.rb b/actionpack/test/abstract/callbacks_test.rb index 6c04e77c86..1090af3060 100644 --- a/actionpack/test/abstract/callbacks_test.rb +++ b/actionpack/test/abstract/callbacks_test.rb @@ -265,5 +265,51 @@ module AbstractController assert_equal "Hello world Howdy!", controller.response_body end end + + class AliasedCallbacks < ControllerWithCallbacks + before_filter :first + after_filter :second + around_filter :aroundz + + def first + @text = "Hello world" + end + + def second + @second = "Goodbye" + end + + def aroundz + @aroundz = "FIRST" + yield + @aroundz << "SECOND" + end + + def index + @text ||= nil + self.response_body = @text.to_s + end + end + + class TestAliasedCallbacks < ActiveSupport::TestCase + def setup + @controller = AliasedCallbacks.new + end + + test "before_filter works" do + @controller.process(:index) + assert_equal "Hello world", @controller.response_body + end + + test "after_filter works" do + @controller.process(:index) + assert_equal "Goodbye", @controller.instance_variable_get("@second") + end + + test "around_filter works" do + @controller.process(:index) + assert_equal "FIRSTSECOND", @controller.instance_variable_get("@aroundz") + end + end end end |