1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

add tests to aliased _filter callbacks

This commit is contained in:
Francesco Rodriguez 2012-12-07 15:29:51 -05:00
parent 5fb94ec044
commit 1b97d41e52

View file

@ -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