aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorCarlhuda <carlhuda@engineyard.com>2010-03-02 18:57:02 -0800
committerCarl Lerche <carllerche@mac.com>2010-03-03 21:23:34 -0800
commit5e0a05b8cb236d285ebb45de006dd3600c69357d (patch)
tree8fd61eaaa83407c6880bd94c9c3d662cf5c28a84 /actionpack/test
parentbcfb77782b9d7f28f0c19005da909162e5e27690 (diff)
downloadrails-5e0a05b8cb236d285ebb45de006dd3600c69357d.tar.gz
rails-5e0a05b8cb236d285ebb45de006dd3600c69357d.tar.bz2
rails-5e0a05b8cb236d285ebb45de006dd3600c69357d.zip
Tweak the semantic of various URL related methods of ActionDispatch::Request
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/http_digest_authentication_test.rb10
-rw-r--r--actionpack/test/controller/integration_test.rb4
-rw-r--r--actionpack/test/dispatch/request_test.rb86
-rw-r--r--actionpack/test/template/url_helper_test.rb3
4 files changed, 16 insertions, 87 deletions
diff --git a/actionpack/test/controller/http_digest_authentication_test.rb b/actionpack/test/controller/http_digest_authentication_test.rb
index 22d2e23de1..6f167fe627 100644
--- a/actionpack/test/controller/http_digest_authentication_test.rb
+++ b/actionpack/test/controller/http_digest_authentication_test.rb
@@ -139,7 +139,7 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
test "authentication request with request-uri that doesn't match credentials digest-uri" do
@request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'please')
- @request.env['REQUEST_URI'] = "/http_digest_authentication_test/dummy_digest/altered/uri"
+ @request.env['PATH_INFO'] = "/http_digest_authentication_test/dummy_digest/altered/uri"
get :display
assert_response :unauthorized
@@ -148,7 +148,8 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
test "authentication request with absolute request uri (as in webrick)" do
@request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'please')
- @request.env['REQUEST_URI'] = "http://test.host/http_digest_authentication_test/dummy_digest"
+ @request.env["SERVER_NAME"] = "test.host"
+ @request.env['PATH_INFO'] = "/http_digest_authentication_test/dummy_digest"
get :display
@@ -171,7 +172,8 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
test "authentication request with absolute uri in both request and credentials (as in Webrick with IE)" do
@request.env['HTTP_AUTHORIZATION'] = encode_credentials(:url => "http://test.host/http_digest_authentication_test/dummy_digest",
:username => 'pretty', :password => 'please')
- @request.env['REQUEST_URI'] = "http://test.host/http_digest_authentication_test/dummy_digest"
+ @request.env['SERVER_NAME'] = "test.host"
+ @request.env['PATH_INFO'] = "/http_digest_authentication_test/dummy_digest"
get :display
@@ -226,7 +228,7 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
credentials = decode_credentials(@response.headers['WWW-Authenticate'])
credentials.merge!(options)
- credentials.merge!(:uri => @request.env['REQUEST_URI'].to_s)
+ credentials.merge!(:uri => @request.env['PATH_INFO'].to_s)
ActionController::HttpAuthentication::Digest.encode_credentials(method, credentials, password, options[:password_is_ha1])
end
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb
index c38348fa68..814699978d 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -346,8 +346,8 @@ class IntegrationProcessTest < ActionController::IntegrationTest
def test_get_with_parameters
with_test_route_set do
get '/get_with_params', :foo => "bar"
- assert_equal '/get_with_params', request.env["REQUEST_URI"]
- assert_equal '/get_with_params', request.request_uri
+ assert_equal '/get_with_params', request.env["PATH_INFO"]
+ assert_equal '/get_with_params', request.path_info
assert_equal 'foo=bar', request.env["QUERY_STRING"]
assert_equal 'foo=bar', request.query_string
assert_equal 'bar', request.parameters['foo']
diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb
index 703f03fa96..1dfcdaebfd 100644
--- a/actionpack/test/dispatch/request_test.rb
+++ b/actionpack/test/dispatch/request_test.rb
@@ -144,103 +144,33 @@ class RequestTest < ActiveSupport::TestCase
end
test "request uri" do
- request = stub_request 'REQUEST_URI' => "http://www.rubyonrails.org/path/of/some/uri?mapped=1"
+ request = stub_request 'SCRIPT_NAME' => '', 'PATH_INFO' => '/path/of/some/uri', 'QUERY_STRING' => 'mapped=1'
assert_equal "/path/of/some/uri?mapped=1", request.request_uri
assert_equal "/path/of/some/uri", request.path
- request = stub_request 'REQUEST_URI' => "http://www.rubyonrails.org/path/of/some/uri"
+ request = stub_request 'SCRIPT_NAME' => '', 'PATH_INFO' => '/path/of/some/uri'
assert_equal "/path/of/some/uri", request.request_uri
assert_equal "/path/of/some/uri", request.path
- request = stub_request 'REQUEST_URI' => "/path/of/some/uri"
- assert_equal "/path/of/some/uri", request.request_uri
- assert_equal "/path/of/some/uri", request.path
-
- request = stub_request 'REQUEST_URI' => "/"
+ request = stub_request 'SCRIPT_NAME' => '', 'PATH_INFO' => '/'
assert_equal "/", request.request_uri
assert_equal "/", request.path
- request = stub_request 'REQUEST_URI' => "/?m=b"
+ request = stub_request 'SCRIPT_NAME' => '', 'PATH_INFO' => '/', 'QUERY_STRING' => 'm=b'
assert_equal "/?m=b", request.request_uri
assert_equal "/", request.path
- request = stub_request 'REQUEST_URI' => "/", 'SCRIPT_NAME' => '/dispatch.cgi'
- assert_equal "/", request.request_uri
- assert_equal "/", request.path
-
- ActionController::Base.relative_url_root = "/hieraki"
- request = stub_request 'REQUEST_URI' => "/hieraki/", 'SCRIPT_NAME' => "/hieraki/dispatch.cgi"
+ request = stub_request 'SCRIPT_NAME' => '/hieraki', 'PATH_INFO' => '/'
assert_equal "/hieraki/", request.request_uri
assert_equal "/", request.path
- ActionController::Base.relative_url_root = nil
- ActionController::Base.relative_url_root = "/collaboration/hieraki"
- request = stub_request 'REQUEST_URI' => "/collaboration/hieraki/books/edit/2",
- 'SCRIPT_NAME' => "/collaboration/hieraki/dispatch.cgi"
+ request = stub_request 'SCRIPT_NAME' => '/collaboration/hieraki', 'PATH_INFO' => '/books/edit/2'
assert_equal "/collaboration/hieraki/books/edit/2", request.request_uri
assert_equal "/books/edit/2", request.path
- ActionController::Base.relative_url_root = nil
-
- # The following tests are for when REQUEST_URI is not supplied (as in IIS)
- request = stub_request 'PATH_INFO' => "/path/of/some/uri?mapped=1",
- 'SCRIPT_NAME' => nil,
- 'REQUEST_URI' => nil
- assert_equal "/path/of/some/uri?mapped=1", request.request_uri
- assert_equal "/path/of/some/uri", request.path
- ActionController::Base.relative_url_root = '/path'
- request = stub_request 'PATH_INFO' => "/path/of/some/uri?mapped=1",
- 'SCRIPT_NAME' => "/path/dispatch.rb",
- 'REQUEST_URI' => nil
+ request = stub_request 'SCRIPT_NAME' => '/path', 'PATH_INFO' => '/of/some/uri', 'QUERY_STRING' => 'mapped=1'
assert_equal "/path/of/some/uri?mapped=1", request.request_uri
assert_equal "/of/some/uri", request.path
- ActionController::Base.relative_url_root = nil
-
- request = stub_request 'PATH_INFO' => "/path/of/some/uri",
- 'SCRIPT_NAME' => nil,
- 'REQUEST_URI' => nil
- assert_equal "/path/of/some/uri", request.request_uri
- assert_equal "/path/of/some/uri", request.path
-
- request = stub_request 'PATH_INFO' => '/', 'REQUEST_URI' => nil
- assert_equal "/", request.request_uri
- assert_equal "/", request.path
-
- request = stub_request 'PATH_INFO' => '/?m=b', 'REQUEST_URI' => nil
- assert_equal "/?m=b", request.request_uri
- assert_equal "/", request.path
-
- request = stub_request 'PATH_INFO' => "/",
- 'SCRIPT_NAME' => "/dispatch.cgi",
- 'REQUEST_URI' => nil
- assert_equal "/", request.request_uri
- assert_equal "/", request.path
-
- ActionController::Base.relative_url_root = '/hieraki'
- request = stub_request 'PATH_INFO' => "/hieraki/",
- 'SCRIPT_NAME' => "/hieraki/dispatch.cgi",
- 'REQUEST_URI' => nil
- assert_equal "/hieraki/", request.request_uri
- assert_equal "/", request.path
- ActionController::Base.relative_url_root = nil
-
- request = stub_request 'REQUEST_URI' => '/hieraki/dispatch.cgi'
- ActionController::Base.relative_url_root = '/hieraki'
- assert_equal "/dispatch.cgi", request.path
- ActionController::Base.relative_url_root = nil
-
- request = stub_request 'REQUEST_URI' => '/hieraki/dispatch.cgi'
- ActionController::Base.relative_url_root = '/foo'
- assert_equal "/hieraki/dispatch.cgi", request.path
- ActionController::Base.relative_url_root = nil
-
- # This test ensures that Rails uses REQUEST_URI over PATH_INFO
- ActionController::Base.relative_url_root = nil
- request = stub_request 'REQUEST_URI' => "/some/path",
- 'PATH_INFO' => "/another/path",
- 'SCRIPT_NAME' => "/dispatch.cgi"
- assert_equal "/some/path", request.request_uri
- assert_equal "/some/path", request.path
end
@@ -498,7 +428,7 @@ class RequestTest < ActiveSupport::TestCase
protected
- def stub_request(env={})
+ def stub_request(env = {})
ActionDispatch::Request.new(env)
end
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb
index b047466aaf..afec78ddce 100644
--- a/actionpack/test/template/url_helper_test.rb
+++ b/actionpack/test/template/url_helper_test.rb
@@ -464,8 +464,6 @@ end
class LinkToUnlessCurrentWithControllerTest < ActionController::TestCase
def setup
super
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
@controller = TasksController.new
end
@@ -565,7 +563,6 @@ end
class PolymorphicControllerTest < ActionController::TestCase
def setup
super
- @request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end