From 87eb02c9301142d1b893b811d9cd9d149c40220d Mon Sep 17 00:00:00 2001 From: rohit Date: Tue, 18 May 2010 10:56:15 +0530 Subject: [PATCH] Added a failing test for inherited before_filter [#3913 state:commited] --- actionpack/test/abstract/callbacks_test.rb | 36 ++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-) diff --git a/actionpack/test/abstract/callbacks_test.rb b/actionpack/test/abstract/callbacks_test.rb index 0ce1dc5..516da7d 100644 --- a/actionpack/test/abstract/callbacks_test.rb +++ b/actionpack/test/abstract/callbacks_test.rb @@ -6,6 +6,42 @@ module AbstractController class ControllerWithCallbacks < AbstractController::Base include AbstractController::Callbacks end + + class ControllerWithCallbackDefined < AbstractController::Base + include AbstractController::Callbacks + + before_filter :baboon + + def baboon + @message = "Baboon!" + end + end + + class Callback_inherit < ControllerWithCallbackDefined + before_filter :baboon, :except => :index + + def index + self.response_body = @message + end + + def show + self.response_body = @message + end + end + + class TestCallback_inherit < ActiveSupport::TestCase + test "should skip inherited callback" do + controller = Callback_inherit.new + result = controller.process(:index) + assert_equal "", controller.response_body + end + + test "should use inherited callback" do + controller = Callback_inherit.new + result = controller.process(:show) + assert_equal "Baboon!", controller.response_body + end + end class Callback1 < ControllerWithCallbacks set_callback :process_action, :before, :first -- 1.7.0.4