diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index 330fa276d01614615d68c36cfd1c382b33c94c89..c95332220bdd4a23c47e221799032bd304b3d781 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/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: #", 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 diff --git a/actionpack/test/fixtures/filter_test/implicit_actions/edit.html.erb b/actionpack/test/fixtures/filter_test/implicit_actions/edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..8491ab9f808dfd844a004aada375effb478697d4 --- /dev/null +++ b/actionpack/test/fixtures/filter_test/implicit_actions/edit.html.erb @@ -0,0 +1 @@ +edit \ No newline at end of file diff --git a/actionpack/test/fixtures/filter_test/implicit_actions/show.html.erb b/actionpack/test/fixtures/filter_test/implicit_actions/show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..0a89cecf05f44873b007616a8b6354299b7fed7a --- /dev/null +++ b/actionpack/test/fixtures/filter_test/implicit_actions/show.html.erb @@ -0,0 +1 @@ +show \ No newline at end of file