From 4859b6c09e188462b4d29328c0bb891cd98d8f31 Mon Sep 17 00:00:00 2001 From: Marcel Molina Date: Wed, 5 Apr 2006 04:39:59 +0000 Subject: Honor skipping filters conditionally for only certain actions even when the parent class sets that filter to conditionally be executed only for the same actions. Closes #4522. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4167 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/filters_test.rb | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index 59bff76536..2459236002 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -126,7 +126,23 @@ class FilterTest < Test::Unit::TestCase render :inline => "ran action" end end - + + class ConditionalParentOfConditionalSkippingController < ConditionalFilterController + before_filter :conditional_in_parent, :only => [:show, :another_action] + after_filter :conditional_in_parent, :only => [:show, :another_action] + + private + + def conditional_in_parent + @ran_filter ||= [] + @ran_filter << 'conditional_in_parent' + end + end + + class ChildOfConditionalParentController < ConditionalParentOfConditionalSkippingController + skip_before_filter :conditional_in_parent, :only => :another_action + skip_after_filter :conditional_in_parent, :only => :another_action + end class ProcController < PrependingController before_filter(proc { |c| c.assigns["ran_proc_filter"] = true }) @@ -372,6 +388,11 @@ class FilterTest < Test::Unit::TestCase assert_equal %w( clean_up ), test_process(ConditionalSkippingController, "change_password").template.controller.instance_variable_get("@ran_after_filter") end + def test_conditional_skipping_of_filters_when_parent_filter_is_also_conditional + assert_equal %w( conditional_in_parent conditional_in_parent ), test_process(ChildOfConditionalParentController).template.assigns['ran_filter'] + assert_nil test_process(ChildOfConditionalParentController, 'another_action').template.assigns['ran_filter'] + end + private def test_process(controller, action = "show") request = ActionController::TestRequest.new -- cgit v1.2.3