mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add a failing test case for an implicit action with a before filter.
Signed-off-by: Andrew White <andyw@pixeltrix.co.uk>
This commit is contained in:
parent
c5908a8649
commit
5da9a74bd3
3 changed files with 24 additions and 0 deletions
|
@ -505,6 +505,16 @@ class FilterTest < ActionController::TestCase
|
|||
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 @@ class FilterTest < ActionController::TestCase
|
|||
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
|
||||
|
|
1
actionpack/test/fixtures/filter_test/implicit_actions/edit.html.erb
vendored
Normal file
1
actionpack/test/fixtures/filter_test/implicit_actions/edit.html.erb
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
edit
|
1
actionpack/test/fixtures/filter_test/implicit_actions/show.html.erb
vendored
Normal file
1
actionpack/test/fixtures/filter_test/implicit_actions/show.html.erb
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
show
|
Loading…
Reference in a new issue