diff options
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/filters.rb | 3 | ||||
-rw-r--r-- | actionpack/test/controller/filters_test.rb | 33 |
3 files changed, 38 insertions, 0 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index cc6c692af6..bcc258acc2 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fix regression from filter refactoring where re-adding a skipped filter resulted in it being called twice. [rick] + * Refactor filters to use Active Support callbacks. #11235 [Josh Peek] * Fixed that polymorphic routes would modify the input array #11363 [thomas.lee] diff --git a/actionpack/lib/action_controller/filters.rb b/actionpack/lib/action_controller/filters.rb index a822ffe4e4..218a9c0b80 100644 --- a/actionpack/lib/action_controller/filters.rb +++ b/actionpack/lib/action_controller/filters.rb @@ -264,6 +264,9 @@ module ActionController #:nodoc: def skip_filter_in_chain(*filters, &test) filters, conditions = extract_options(filters) + filters.each do |filter| + if callback = find_callback(filter) then delete(callback) end + end if conditions.empty? update_filter_in_chain(filters, :skip => conditions, &test) end diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index 092eb45cab..3652c482f1 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -158,6 +158,30 @@ class FilterTest < Test::Unit::TestCase end end + class SkippingAndLimitedController < TestController + skip_before_filter :ensure_login + before_filter :ensure_login, :only => :index + + def index + render :text => 'ok' + end + + def public + end + end + + class SkippingAndReorderingController < TestController + skip_before_filter :ensure_login + before_filter :find_record + before_filter :ensure_login + + private + def find_record + @ran_filter ||= [] + @ran_filter << "find_record" + end + end + class ConditionalSkippingController < TestController skip_before_filter :ensure_login, :only => [ :login ] skip_after_filter :clean_up, :only => [ :login ] @@ -565,6 +589,15 @@ class FilterTest < Test::Unit::TestCase response = test_process(PrependingBeforeAndAfterController) assert_equal %w( before_all between_before_all_and_after_all after_all ), response.template.assigns["ran_filter"] end + + def test_skipping_and_limiting_controller + assert_equal %w( ensure_login ), test_process(SkippingAndLimitedController, "index").template.assigns["ran_filter"] + assert_nil test_process(SkippingAndLimitedController, "public").template.assigns["ran_filter"] + end + + def test_skipping_and_reordering_controller + assert_equal %w( find_record ensure_login ), test_process(SkippingAndReorderingController, "index").template.assigns["ran_filter"] + end def test_conditional_skipping_of_filters assert_nil test_process(ConditionalSkippingController, "login").template.assigns["ran_filter"] |