Permalink
Browse files

Fix regression from filter refactoring where re-adding a skipped filt…

…er resulted in it being called twice. [rick]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9080 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 29e3316 commit 038139870825ad843b0683e5273dc4d11cb684b3 @technoweenie technoweenie committed Mar 23, 2008
Showing with 38 additions and 0 deletions.
  1. +2 −0 actionpack/CHANGELOG
  2. +3 −0 actionpack/lib/action_controller/filters.rb
  3. +33 −0 actionpack/test/controller/filters_test.rb
View
@@ -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]
@@ -264,6 +264,9 @@ def create_filters(filters, filter_type, &block)
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
@@ -158,6 +158,30 @@ def wonderful_life
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 @@ def test_running_prepended_before_and_after_filter
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"]

0 comments on commit 0381398

Please sign in to comment.