Skip to content

Commit

Permalink
add tests to aliased _filter callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Rodriguez committed Dec 7, 2012
1 parent 5fb94ec commit 1b97d41
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions actionpack/test/abstract/callbacks_test.rb
Expand Up @@ -265,5 +265,51 @@ class TestCallbacksWithArgs < ActiveSupport::TestCase
assert_equal "Hello world Howdy!", controller.response_body assert_equal "Hello world Howdy!", controller.response_body
end end
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
end end

0 comments on commit 1b97d41

Please sign in to comment.