aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/filters_test.rb
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2007-05-06 04:10:26 +0000
committerMichael Koziarski <michael@koziarski.com>2007-05-06 04:10:26 +0000
commit67ca9224d709e28bfd5802b1f44969d621b0ea8f (patch)
treec5d970f3f65aaca597f762ed3e6d58076ebf2b46 /actionpack/test/controller/filters_test.rb
parente64236882919a6696ff64a4e3e736955b4d09753 (diff)
downloadrails-67ca9224d709e28bfd5802b1f44969d621b0ea8f.tar.gz
rails-67ca9224d709e28bfd5802b1f44969d621b0ea8f.tar.bz2
rails-67ca9224d709e28bfd5802b1f44969d621b0ea8f.zip
Bug fix for the filter implementation
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6669 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller/filters_test.rb')
-rw-r--r--actionpack/test/controller/filters_test.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb
index f250b24f00..e84661b688 100644
--- a/actionpack/test/controller/filters_test.rb
+++ b/actionpack/test/controller/filters_test.rb
@@ -131,6 +131,14 @@ class FilterTest < Test::Unit::TestCase
before_filter(ConditionalClassFilter, :ensure_login, Proc.new {|c| c.assigns["ran_proc_filter1"] = true }, :except => :show_without_filter) { |c| c.assigns["ran_proc_filter2"] = true}
end
+ class EmptyFilterChainController < TestController
+ self.filter_chain.clear
+ def show
+ @action_executed = true
+ render :text => "yawp!"
+ end
+ end
+
class PrependingController < TestController
prepend_before_filter :wonderful_life
# skip_before_filter :fire_flash
@@ -293,6 +301,35 @@ class FilterTest < Test::Unit::TestCase
end
end
+ class PrependingBeforeAndAfterController < ActionController::Base
+ prepend_before_filter :before_all
+ prepend_after_filter :after_all
+ before_filter :between_before_all_and_after_all
+
+ def before_all
+ @ran_filter ||= []
+ @ran_filter << 'before_all'
+ end
+
+ def after_all
+ @ran_filter ||= []
+ @ran_filter << 'after_all'
+ end
+
+ def between_before_all_and_after_all
+ @ran_filter ||= []
+ @ran_filter << 'between_before_all_and_after_all'
+ end
+ def show
+ render :text => 'hello'
+ end
+ end
+
+ def test_empty_filter_chain
+ assert_equal 0, EmptyFilterChainController.filter_chain.size
+ assert test_process(EmptyFilterChainController).template.assigns['action_executed']
+ end
+
def test_added_filter_to_inheritance_graph
assert_equal [ :ensure_login ], TestController.before_filters
end
@@ -426,6 +463,12 @@ class FilterTest < Test::Unit::TestCase
end
end
+ def test_running_prepended_before_and_after_filter
+ assert_equal 3, PrependingBeforeAndAfterController.filter_chain.length
+ 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_conditional_skipping_of_filters
assert_nil test_process(ConditionalSkippingController, "login").template.assigns["ran_filter"]
assert_equal %w( ensure_login find_user ), test_process(ConditionalSkippingController, "change_password").template.assigns["ran_filter"]