diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-03-18 17:56:05 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-03-18 17:56:05 +0000 |
commit | 856a4dcf1207e888b23016cac6a64582051aa0ff (patch) | |
tree | 6ab4bf4149122d70f457e597bf4dc5e4defe5629 /actionpack/test/controller | |
parent | 9af9fc3da19fb06e965d977339bfb79ab014bcb7 (diff) | |
download | rails-856a4dcf1207e888b23016cac6a64582051aa0ff.tar.gz rails-856a4dcf1207e888b23016cac6a64582051aa0ff.tar.bz2 rails-856a4dcf1207e888b23016cac6a64582051aa0ff.zip |
Refactor filters to use Active Support callbacks. Closes #11235.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9055 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/dispatcher_test.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/filters_test.rb | 25 |
2 files changed, 11 insertions, 16 deletions
diff --git a/actionpack/test/controller/dispatcher_test.rb b/actionpack/test/controller/dispatcher_test.rb index fe9789c698..c64defeed4 100644 --- a/actionpack/test/controller/dispatcher_test.rb +++ b/actionpack/test/controller/dispatcher_test.rb @@ -11,7 +11,7 @@ class DispatcherTest < Test::Unit::TestCase @output = StringIO.new ENV['REQUEST_METHOD'] = 'GET' - Dispatcher.instance_variable_set("@prepare_dispatch_callbacks", []) + Dispatcher.instance_variable_set("@prepare_dispatch_callbacks", ActiveSupport::Callbacks::CallbackChain.new) @dispatcher = Dispatcher.new(@output) end diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index 7cf2c9d318..092eb45cab 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -134,6 +134,11 @@ 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 ConditionalOptionsFilter < ConditionalFilterController + before_filter :ensure_login, :if => Proc.new { |c| true } + before_filter :clean_up_tmp, :if => Proc.new { |c| false } + end + class EmptyFilterChainController < TestController self.filter_chain.clear def show @@ -466,6 +471,11 @@ class FilterTest < Test::Unit::TestCase assert !response.template.assigns["ran_proc_filter2"] end + def test_running_conditional_options + response = test_process(ConditionalOptionsFilter) + assert_equal %w( ensure_login ), response.template.assigns["ran_filter"] + end + def test_running_collection_condition_filters assert_equal %w( ensure_login ), test_process(ConditionalCollectionFilterController).template.assigns["ran_filter"] assert_equal nil, test_process(ConditionalCollectionFilterController, "show_without_filter").template.assigns["ran_filter"] @@ -499,13 +509,6 @@ class FilterTest < Test::Unit::TestCase assert_equal nil, test_process(BeforeAndAfterConditionController, "show_without_filter").template.assigns["ran_filter"] end - def test_bad_filter - bad_filter_controller = Class.new(ActionController::Base) - assert_raises(ActionController::ActionControllerError) do - bad_filter_controller.before_filter 2 - end - end - def test_around_filter controller = test_process(AroundFilterController) assert controller.template.assigns["before_ran"] @@ -746,14 +749,6 @@ class YieldingAroundFiltersTest < Test::Unit::TestCase assert_equal 4, ControllerWithAllTypesOfFilters.filter_chain.size end - def test_wrong_filter_type - assert_raise ArgumentError do - Class.new PostsController do - around_filter lambda { yield } - end - end - end - def test_base controller = PostsController assert_nothing_raised { test_process(controller,'no_raise') } |