aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManfred Stienstra <manfred@fngtps.com>2011-02-25 12:34:46 +0100
committerAndrew White <andyw@pixeltrix.co.uk>2011-03-23 23:32:44 +0000
commit5da9a74bd35284cf5124793c1f7558e506b52592 (patch)
treedbfbdb38ecc08317426cd7f70e57e3d7acdc630f
parentc5908a86492271ca55a6f54ccfd62b521cdc47c9 (diff)
downloadrails-5da9a74bd35284cf5124793c1f7558e506b52592.tar.gz
rails-5da9a74bd35284cf5124793c1f7558e506b52592.tar.bz2
rails-5da9a74bd35284cf5124793c1f7558e506b52592.zip
Add a failing test case for an implicit action with a before filter.
Signed-off-by: Andrew White <andyw@pixeltrix.co.uk>
-rw-r--r--actionpack/test/controller/filters_test.rb22
-rw-r--r--actionpack/test/fixtures/filter_test/implicit_actions/edit.html.erb1
-rw-r--r--actionpack/test/fixtures/filter_test/implicit_actions/show.html.erb1
3 files changed, 24 insertions, 0 deletions
diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb
index 330fa276d0..c95332220b 100644
--- a/actionpack/test/controller/filters_test.rb
+++ b/actionpack/test/controller/filters_test.rb
@@ -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
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 0000000000..8491ab9f80
--- /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 0000000000..0a89cecf05
--- /dev/null
+++ b/actionpack/test/fixtures/filter_test/implicit_actions/show.html.erb
@@ -0,0 +1 @@
+show \ No newline at end of file