diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-04-30 17:26:03 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-04-30 17:26:03 -0500 |
commit | 00d1a57e9f99a1b2439281cb741fd82ef47a5c55 (patch) | |
tree | 3fafedd0ef5870df4c8d603aab7dadf3f833a977 /actionpack/test | |
parent | 64e66cf161ee8db0bdbccb1be18fb760f5a9d24e (diff) | |
download | rails-00d1a57e9f99a1b2439281cb741fd82ef47a5c55.tar.gz rails-00d1a57e9f99a1b2439281cb741fd82ef47a5c55.tar.bz2 rails-00d1a57e9f99a1b2439281cb741fd82ef47a5c55.zip |
Start moving TestRequest and TestResponse into ActionDispatch
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/action_pack_assertions_test.rb | 22 | ||||
-rw-r--r-- | actionpack/test/controller/caching_test.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 8 | ||||
-rw-r--r-- | actionpack/test/controller/test_test.rb | 4 | ||||
-rw-r--r-- | actionpack/test/dispatch/test_request_test.rb | 30 |
5 files changed, 51 insertions, 15 deletions
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb index dd59999a0c..711640f9a9 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -305,24 +305,30 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase # check the empty flashing def test_flash_me_naked process :flash_me_naked - assert !@response.has_flash? - assert !@response.has_flash_with_contents? + assert_deprecated do + assert !@response.has_flash? + assert !@response.has_flash_with_contents? + end end # check if we have flash objects def test_flash_haves process :flash_me - assert @response.has_flash? - assert @response.has_flash_with_contents? - assert @response.has_flash_object?('hello') + assert_deprecated do + assert @response.has_flash? + assert @response.has_flash_with_contents? + assert @response.has_flash_object?('hello') + end end # ensure we don't have flash objects def test_flash_have_nots process :nothing - assert !@response.has_flash? - assert !@response.has_flash_with_contents? - assert_nil @response.flash['hello'] + assert_deprecated do + assert !@response.has_flash? + assert !@response.has_flash_with_contents? + assert_nil @response.flash['hello'] + end end # check if we were rendered by a file-based template? diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index b61a58dd09..df1a1b7683 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -345,7 +345,7 @@ class ActionCacheTest < ActionController::TestCase cached_time = content_to_cache reset! - @request.set_REQUEST_URI "/action_caching_test/expire.xml" + @request.request_uri = "/action_caching_test/expire.xml" get :expire, :format => :xml reset! diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index ef56119751..77abb68f32 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -1923,7 +1923,7 @@ class RouteSetTest < Test::Unit::TestCase end end - request.path = "/people" + request.request_uri = "/people" request.env["REQUEST_METHOD"] = "GET" assert_nothing_raised { set.recognize(request) } assert_equal("index", request.path_parameters[:action]) @@ -1945,7 +1945,7 @@ class RouteSetTest < Test::Unit::TestCase } request.recycle! - request.path = "/people/5" + request.request_uri = "/people/5" request.env["REQUEST_METHOD"] = "GET" assert_nothing_raised { set.recognize(request) } assert_equal("show", request.path_parameters[:action]) @@ -2047,7 +2047,7 @@ class RouteSetTest < Test::Unit::TestCase end end - request.path = "/people/5" + request.request_uri = "/people/5" request.env["REQUEST_METHOD"] = "GET" assert_nothing_raised { set.recognize(request) } assert_equal("show", request.path_parameters[:action]) @@ -2059,7 +2059,7 @@ class RouteSetTest < Test::Unit::TestCase assert_equal("update", request.path_parameters[:action]) request.recycle! - request.path = "/people/5.png" + request.request_uri = "/people/5.png" request.env["REQUEST_METHOD"] = "GET" assert_nothing_raised { set.recognize(request) } assert_equal("show", request.path_parameters[:action]) diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index b372980242..919f9815ec 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -201,7 +201,7 @@ XML end def test_process_with_request_uri_with_params_with_explicit_uri - @request.set_REQUEST_URI "/explicit/uri" + @request.request_uri = "/explicit/uri" process :test_uri, :id => 7 assert_equal "/explicit/uri", @response.body end @@ -212,7 +212,7 @@ XML end def test_process_with_query_string_with_explicit_uri - @request.set_REQUEST_URI "/explicit/uri?q=test?extra=question" + @request.request_uri = "/explicit/uri?q=test?extra=question" process :test_query_string assert_equal "q=test?extra=question", @response.body end diff --git a/actionpack/test/dispatch/test_request_test.rb b/actionpack/test/dispatch/test_request_test.rb new file mode 100644 index 0000000000..40a7f04079 --- /dev/null +++ b/actionpack/test/dispatch/test_request_test.rb @@ -0,0 +1,30 @@ +require 'abstract_unit' + +class TestRequestTest < ActiveSupport::TestCase + test "sane defaults" do + env = ActionDispatch::TestRequest.new.env + + assert_equal "GET", env.delete("REQUEST_METHOD") + assert_equal "off", env.delete("HTTPS") + assert_equal "http", env.delete("rack.url_scheme") + assert_equal "example.org", env.delete("SERVER_NAME") + assert_equal "80", env.delete("SERVER_PORT") + assert_equal "/", env.delete("PATH_INFO") + assert_equal "", env.delete("SCRIPT_NAME") + assert_equal "", env.delete("QUERY_STRING") + assert_equal "0", env.delete("CONTENT_LENGTH") + + assert_equal "test.host", env.delete("HTTP_HOST") + assert_equal "0.0.0.0", env.delete("REMOTE_ADDR") + assert_equal "Rails Testing", env.delete("HTTP_USER_AGENT") + + assert_equal [0, 1], env.delete("rack.version") + assert_equal "", env.delete("rack.input").string + assert_kind_of StringIO, env.delete("rack.errors") + assert_equal true, env.delete("rack.multithread") + assert_equal true, env.delete("rack.multiprocess") + assert_equal false, env.delete("rack.run_once") + + assert env.empty?, env.inspect + end +end |