Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

Signed-off-by: Andrew White <andyw@pixeltrix.co.uk>
  • Loading branch information...
commit 5da9a74bd35284cf5124793c1f7558e506b52592 1 parent c5908a8
@Manfred Manfred authored pixeltrix committed
View
22 actionpack/test/controller/filters_test.rb
@@ -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
View
1  actionpack/test/fixtures/filter_test/implicit_actions/edit.html.erb
@@ -0,0 +1 @@
+edit
View
1  actionpack/test/fixtures/filter_test/implicit_actions/show.html.erb
@@ -0,0 +1 @@
+show
Please sign in to comment.
Something went wrong with that request. Please try again.