From 2ee84cc6f92d49ec7004d0c99d66c6feb05cee9c Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 20 Jan 2005 14:13:34 +0000 Subject: Fixed that all redirect and render calls now return true, so you can use the pattern of "do and return". Added that renders and redirects called in before_filters will have the same effect as returning false: stopping the chain. Added that only one render or redirect can happen per action. The first call wins and subsequent calls are ignored. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@462 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/filters_test.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index 58490aebba..2cc51f1e25 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -14,6 +14,20 @@ class FilterTest < Test::Unit::TestCase @ran_filter << "ensure_login" end end + + class RenderingController < ActionController::Base + before_filter :render_something_else + + def show + @ran_action = true + render_text "ran action" + end + + private + def render_something_else + render_text "something else" + end + end class ConditionalFilterController < ActionController::Base def show @@ -264,6 +278,12 @@ class FilterTest < Test::Unit::TestCase " after appended aroundfilter after aroundfilter after procfilter ", MixedFilterController.execution_log end + + def test_rendering_breaks_filtering_chain + response = test_process(RenderingController) + assert_equal "something else", response.body + assert !response.template.assigns["ran_action"] + end private def test_process(controller, action = "show") -- cgit v1.2.3