提交 5da9a74b 编写于 作者: M Manfred Stienstra 提交者: Andrew White

Add a failing test case for an implicit action with a before filter.

Signed-off-by: NAndrew White <andyw@pixeltrix.co.uk>
上级 c5908a86
......@@ -505,6 +505,16 @@ def show
end
end
class ImplicitActionsController < ActionController::Base
before_filter :find_user, :only => :edit
private
def find_user
@user = 'Jenny'
end
end
def test_sweeper_should_not_block_rendering
response = test_process(SweeperTestController)
assert_equal 'hello world', response.body
......@@ -783,6 +793,18 @@ def test_a_rescuing_around_filter
assert_equal("I rescued this: #<FilterTest::ErrorToRescue: Something made the bad noise.>", response.body)
end
def test_filter_runs_for_implicitly_defined_action_when_needed
test_process(ImplicitActionsController, 'edit')
assert_equal 'Jenny', assigns(:user)
assert_equal 'edit', response.body
end
def test_filter_does_not_run_for_implicity_defined_action_when_not_needed
test_process(ImplicitActionsController, 'show')
assert_nil assigns(:user)
assert_equal 'show', response.body
end
private
def test_process(controller, action = "show")
@controller = controller.is_a?(Class) ? controller.new : controller
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册