diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2011-03-23 23:09:00 +0000 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2011-03-23 23:32:44 +0000 |
commit | 9772de8d459960cc114c5b214343b7ce08fea21c (patch) | |
tree | d103db091da987a1af5b3d01d1e7719c260e3927 /actionpack/test/controller | |
parent | 5da9a74bd35284cf5124793c1f7558e506b52592 (diff) | |
download | rails-9772de8d459960cc114c5b214343b7ce08fea21c.tar.gz rails-9772de8d459960cc114c5b214343b7ce08fea21c.tar.bz2 rails-9772de8d459960cc114c5b214343b7ce08fea21c.zip |
Fix filter :only and :except with implicit actions
The method_name argument is "default_render" for implicit actions
so use the action_name attribute to determine which callbacks to run.
[#5673 state:resolved]
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/filters_test.rb | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index c95332220b..9e44e8e088 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -506,12 +506,17 @@ class FilterTest < ActionController::TestCase end class ImplicitActionsController < ActionController::Base - before_filter :find_user, :only => :edit + before_filter :find_only, :only => :edit + before_filter :find_except, :except => :edit private - def find_user - @user = 'Jenny' + def find_only + @only = 'Only' + end + + def find_except + @except = 'Except' end end @@ -793,16 +798,16 @@ 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 + def test_filters_obey_only_and_except_for_implicit_actions test_process(ImplicitActionsController, 'show') - assert_nil assigns(:user) + assert_equal 'Except', assigns(:except) + assert_nil assigns(:only) assert_equal 'show', response.body + + test_process(ImplicitActionsController, 'edit') + assert_equal 'Only', assigns(:only) + assert_nil assigns(:except) + assert_equal 'edit', response.body end private |