From 35fa00731329120fa1d0c2a9d66af6813203195a Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 7 Jan 2009 13:23:10 -0800 Subject: Include process methods in ActionController::TestCase only. No need to alias_method_chain :process either. --- .../test/controller/addresses_render_test.rb | 9 +++------ actionpack/test/controller/base_test.rb | 22 ++++++++++------------ actionpack/test/controller/benchmark_test.rb | 6 +++--- actionpack/test/controller/capture_test.rb | 9 +++------ actionpack/test/controller/content_type_test.rb | 9 +++------ actionpack/test/controller/cookie_test.rb | 8 +++----- actionpack/test/controller/filters_test.rb | 8 ++++++-- actionpack/test/controller/flash_test.rb | 8 ++------ actionpack/test/controller/send_file_test.rb | 3 ++- 9 files changed, 35 insertions(+), 47 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/addresses_render_test.rb b/actionpack/test/controller/addresses_render_test.rb index b26cae24fb..556b0593ea 100644 --- a/actionpack/test/controller/addresses_render_test.rb +++ b/actionpack/test/controller/addresses_render_test.rb @@ -19,17 +19,14 @@ class AddressesTestController < ActionController::Base def self.controller_path; "addresses"; end end -class AddressesTest < Test::Unit::TestCase - def setup - @controller = AddressesTestController.new +class AddressesTest < ActionController::TestCase + tests AddressesTestController + def setup # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get # a more accurate simulation of what happens in "real life". @controller.logger = Logger.new(nil) - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @request.host = "www.nextangle.com" end diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb index 18d185b264..9523189f41 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -129,6 +129,8 @@ class PerformActionTest < ActionController::TestCase @response = ActionController::TestResponse.new @request.host = "www.nextangle.com" + + rescue_action_in_public! end def test_get_on_priv_should_show_selector @@ -164,14 +166,12 @@ class PerformActionTest < ActionController::TestCase end end -class DefaultUrlOptionsTest < Test::Unit::TestCase - def setup - @controller = DefaultUrlOptionsController.new - - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new +class DefaultUrlOptionsTest < ActionController::TestCase + tests DefaultUrlOptionsController + def setup @request.host = 'www.example.com' + rescue_action_in_public! end def test_default_url_options_are_used_if_set @@ -189,14 +189,12 @@ class DefaultUrlOptionsTest < Test::Unit::TestCase end end -class EmptyUrlOptionsTest < Test::Unit::TestCase - def setup - @controller = NonEmptyController.new - - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new +class EmptyUrlOptionsTest < ActionController::TestCase + tests NonEmptyController + def setup @request.host = 'www.example.com' + rescue_action_in_public! end def test_ensure_url_for_works_as_expected_when_called_with_no_options_if_default_url_options_is_not_set diff --git a/actionpack/test/controller/benchmark_test.rb b/actionpack/test/controller/benchmark_test.rb index 608ea5f5a9..f9100a2313 100644 --- a/actionpack/test/controller/benchmark_test.rb +++ b/actionpack/test/controller/benchmark_test.rb @@ -11,17 +11,17 @@ class BenchmarkedController < ActionController::Base end end -class BenchmarkTest < Test::Unit::TestCase +class BenchmarkTest < ActionController::TestCase + tests BenchmarkedController + class MockLogger def method_missing(*args) end end def setup - @controller = BenchmarkedController.new # benchmark doesn't do anything unless a logger is set @controller.logger = MockLogger.new - @request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new @request.host = "test.actioncontroller.i" end diff --git a/actionpack/test/controller/capture_test.rb b/actionpack/test/controller/capture_test.rb index 5ded6a5d26..6dfa0995eb 100644 --- a/actionpack/test/controller/capture_test.rb +++ b/actionpack/test/controller/capture_test.rb @@ -23,17 +23,14 @@ class CaptureController < ActionController::Base def rescue_action(e) raise end end -class CaptureTest < Test::Unit::TestCase - def setup - @controller = CaptureController.new +class CaptureTest < ActionController::TestCase + tests CaptureController + def setup # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get # a more accurate simulation of what happens in "real life". @controller.logger = Logger.new(nil) - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @request.host = "www.nextangle.com" end diff --git a/actionpack/test/controller/content_type_test.rb b/actionpack/test/controller/content_type_test.rb index ae71d62e11..32c1757ef9 100644 --- a/actionpack/test/controller/content_type_test.rb +++ b/actionpack/test/controller/content_type_test.rb @@ -50,16 +50,13 @@ class ContentTypeController < ActionController::Base def rescue_action(e) raise end end -class ContentTypeTest < Test::Unit::TestCase - def setup - @controller = ContentTypeController.new +class ContentTypeTest < ActionController::TestCase + tests ContentTypeController + def setup # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get # a more accurate simulation of what happens in "real life". @controller.logger = Logger.new(nil) - - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new end def test_render_defaults diff --git a/actionpack/test/controller/cookie_test.rb b/actionpack/test/controller/cookie_test.rb index 3ddc5768a9..9508348ca1 100644 --- a/actionpack/test/controller/cookie_test.rb +++ b/actionpack/test/controller/cookie_test.rb @@ -1,6 +1,6 @@ require 'abstract_unit' -class CookieTest < Test::Unit::TestCase +class CookieTest < ActionController::TestCase class TestController < ActionController::Base def authenticate cookies["user_name"] = "david" @@ -41,11 +41,9 @@ class CookieTest < Test::Unit::TestCase end end - def setup - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new + tests TestController - @controller = TestController.new + def setup @request.host = "www.nextangle.com" end diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index dafa344473..e83fde2349 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -634,9 +634,11 @@ class FilterTest < Test::Unit::TestCase private def test_process(controller, action = "show") + ActionController::Base.class_eval { include ActionController::ProcessWithTest } unless ActionController::Base < ActionController::ProcessWithTest request = ActionController::TestRequest.new request.action = action - controller.process(request, ActionController::TestResponse.new) + controller = controller.new if controller.is_a?(Class) + controller.process_with_test(request, ActionController::TestResponse.new) end end @@ -874,8 +876,10 @@ class YieldingAroundFiltersTest < Test::Unit::TestCase protected def test_process(controller, action = "show") + ActionController::Base.class_eval { include ActionController::ProcessWithTest } unless ActionController::Base < ActionController::ProcessWithTest request = ActionController::TestRequest.new request.action = action - controller.process(request, ActionController::TestResponse.new) + controller = controller.new if controller.is_a?(Class) + controller.process_with_test(request, ActionController::TestResponse.new) end end diff --git a/actionpack/test/controller/flash_test.rb b/actionpack/test/controller/flash_test.rb index e562531bf3..d8a892811e 100644 --- a/actionpack/test/controller/flash_test.rb +++ b/actionpack/test/controller/flash_test.rb @@ -1,6 +1,6 @@ require 'abstract_unit' -class FlashTest < Test::Unit::TestCase +class FlashTest < ActionController::TestCase class TestController < ActionController::Base def set_flash flash["that"] = "hello" @@ -73,11 +73,7 @@ class FlashTest < Test::Unit::TestCase end end - def setup - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @controller = TestController.new - end + tests TestController def test_flash get :set_flash diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb index 1b7486ad34..5fc79baa44 100644 --- a/actionpack/test/controller/send_file_test.rb +++ b/actionpack/test/controller/send_file_test.rb @@ -19,7 +19,8 @@ class SendFileController < ActionController::Base def rescue_action(e) raise end end -class SendFileTest < Test::Unit::TestCase +class SendFileTest < ActionController::TestCase + tests SendFileController include TestFileUtils Mime::Type.register "image/png", :png unless defined? Mime::PNG -- cgit v1.2.3