aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorCarl Lerche <carllerche@mac.com>2010-03-03 22:35:43 -0800
committerCarl Lerche <carllerche@mac.com>2010-03-03 22:35:43 -0800
commit5ce25aecee062c11fc0186ae2df625ba3f013a46 (patch)
tree2c0dc0f69d4ff0dc182cc9f32d59d85257a6723b /actionpack/test/controller
parent2a60cc682224f8a0923de1e0bf769d5333084480 (diff)
parent13a932cddcd3165792d3454009b6d07471031a2c (diff)
downloadrails-5ce25aecee062c11fc0186ae2df625ba3f013a46.tar.gz
rails-5ce25aecee062c11fc0186ae2df625ba3f013a46.tar.bz2
rails-5ce25aecee062c11fc0186ae2df625ba3f013a46.zip
Merge branch 'configuration_refactor'
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/caching_test.rb6
-rw-r--r--actionpack/test/controller/content_type_test.rb12
-rw-r--r--actionpack/test/controller/http_digest_authentication_test.rb15
-rw-r--r--actionpack/test/controller/integration_test.rb6
-rw-r--r--actionpack/test/controller/mime_responds_test.rb4
-rw-r--r--actionpack/test/controller/test_test.rb8
-rw-r--r--actionpack/test/controller/url_for_test.rb15
7 files changed, 23 insertions, 43 deletions
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index 80c968cc04..e42ef85b98 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -51,6 +51,7 @@ class PageCachingTest < ActionController::TestCase
@request = ActionController::TestRequest.new
@request.host = 'hostname.com'
+ @request.env.delete('PATH_INFO')
@response = ActionController::TestResponse.new
@controller = PageCachingTestController.new
@@ -110,7 +111,7 @@ class PageCachingTest < ActionController::TestCase
end
def test_should_cache_ok_at_custom_path
- @request.request_uri = "/index.html"
+ @request.env['PATH_INFO'] = '/index.html'
get :ok
assert_response :ok
assert File.exist?("#{FILE_STORE_PATH}/index.html")
@@ -305,12 +306,9 @@ class ActionCacheTest < ActionController::TestCase
end
def test_action_cache_conditional_options
- old_use_accept_header = ActionController::Base.use_accept_header
- ActionController::Base.use_accept_header = true
@request.env['HTTP_ACCEPT'] = 'application/json'
get :index
assert !fragment_exist?('hostname.com/action_caching_test')
- ActionController::Base.use_accept_header = old_use_accept_header
end
def test_action_cache_with_store_options
diff --git a/actionpack/test/controller/content_type_test.rb b/actionpack/test/controller/content_type_test.rb
index e5ffe20ecc..967107853b 100644
--- a/actionpack/test/controller/content_type_test.rb
+++ b/actionpack/test/controller/content_type_test.rb
@@ -145,18 +145,6 @@ end
class AcceptBasedContentTypeTest < ActionController::TestCase
tests OldContentTypeController
- def setup
- super
- @_old_accept_header = ActionController::Base.use_accept_header
- ActionController::Base.use_accept_header = true
- end
-
- def teardown
- super
- ActionController::Base.use_accept_header = @_old_accept_header
- end
-
-
def test_render_default_content_types_for_respond_to
@request.accept = Mime::HTML.to_s
get :render_default_content_types_for_respond_to
diff --git a/actionpack/test/controller/http_digest_authentication_test.rb b/actionpack/test/controller/http_digest_authentication_test.rb
index 7e9a2625f1..6f167fe627 100644
--- a/actionpack/test/controller/http_digest_authentication_test.rb
+++ b/actionpack/test/controller/http_digest_authentication_test.rb
@@ -40,7 +40,8 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
setup do
# Used as secret in generating nonce to prevent tampering of timestamp
- @old_secret, ActionController::Base.session_options[:secret] = ActionController::Base.session_options[:secret], "session_options_secret"
+ @secret = "session_options_secret"
+ @old_secret, ActionController::Base.session_options[:secret] = ActionController::Base.session_options[:secret], @secret
end
teardown do
@@ -138,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
@@ -147,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
@@ -170,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
@@ -202,7 +205,7 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
test "validate_digest_response should fail with nil returning password_procedure" do
@request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => nil, :password => nil)
- assert !ActionController::HttpAuthentication::Digest.validate_digest_response(@request, "SuperSecret"){nil}
+ assert !ActionController::HttpAuthentication::Digest.validate_digest_response(@secret, @request, "SuperSecret"){nil}
end
private
@@ -225,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..5cb6aa6997 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -333,7 +333,7 @@ class IntegrationProcessTest < ActionController::IntegrationTest
with_test_route_set do
get '/get_with_params?foo=bar'
assert_equal '/get_with_params?foo=bar', request.env["REQUEST_URI"]
- assert_equal '/get_with_params?foo=bar', request.request_uri
+ assert_equal '/get_with_params?foo=bar', request.fullpath
assert_equal "foo=bar", request.env["QUERY_STRING"]
assert_equal 'foo=bar', request.query_string
assert_equal 'bar', request.parameters['foo']
@@ -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/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index 5e34773899..5c1eaf453c 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -155,13 +155,11 @@ class RespondToControllerTest < ActionController::TestCase
def setup
super
- ActionController::Base.use_accept_header = true
@request.host = "www.example.com"
end
def teardown
super
- ActionController::Base.use_accept_header = false
end
def test_html
@@ -544,13 +542,11 @@ class RespondWithControllerTest < ActionController::TestCase
def setup
super
- ActionController::Base.use_accept_header = true
@request.host = "www.example.com"
end
def teardown
super
- ActionController::Base.use_accept_header = false
end
def test_using_resource
diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb
index d716dc2661..f6ba275849 100644
--- a/actionpack/test/controller/test_test.rb
+++ b/actionpack/test/controller/test_test.rb
@@ -42,7 +42,7 @@ class TestTest < ActionController::TestCase
end
def test_uri
- render :text => request.request_uri
+ render :text => request.fullpath
end
def test_query_string
@@ -128,6 +128,7 @@ XML
@controller = TestController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
+ @request.env['PATH_INFO'] = nil
end
def test_raw_post_handling
@@ -199,7 +200,7 @@ XML
end
def test_process_with_request_uri_with_params_with_explicit_uri
- @request.request_uri = "/explicit/uri"
+ @request.env['PATH_INFO'] = "/explicit/uri"
process :test_uri, :id => 7
assert_equal "/explicit/uri", @response.body
end
@@ -210,7 +211,8 @@ XML
end
def test_process_with_query_string_with_explicit_uri
- @request.request_uri = "/explicit/uri?q=test?extra=question"
+ @request.env['PATH_INFO'] = '/explicit/uri'
+ @request.env['QUERY_STRING'] = 'q=test?extra=question'
process :test_query_string
assert_equal "q=test?extra=question", @response.body
end
diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb
index a7b77edc6e..07809aa480 100644
--- a/actionpack/test/controller/url_for_test.rb
+++ b/actionpack/test/controller/url_for_test.rb
@@ -113,15 +113,13 @@ module AbstractController
end
def test_relative_url_root_is_respected
- orig_relative_url_root = ActionController::Base.relative_url_root
- ActionController::Base.relative_url_root = '/subdir'
+ # ROUTES TODO: Tests should not have to pass :relative_url_root directly. This
+ # should probably come from the router.
add_host!
assert_equal('https://www.basecamphq.com/subdir/c/a/i',
- W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https')
+ W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https', :relative_url_root => '/subdir')
)
- ensure
- ActionController::Base.relative_url_root = orig_relative_url_root
end
def test_named_routes
@@ -146,9 +144,6 @@ module AbstractController
end
def test_relative_url_root_is_respected_for_named_routes
- orig_relative_url_root = ActionController::Base.relative_url_root
- ActionController::Base.relative_url_root = '/subdir'
-
with_routing do |set|
set.draw do |map|
match '/home/sweet/home/:user', :to => 'home#index', :as => :home
@@ -158,10 +153,8 @@ module AbstractController
controller = kls.new
assert_equal 'http://www.basecamphq.com/subdir/home/sweet/home/again',
- controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again')
+ controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again', :relative_url_root => "/subdir")
end
- ensure
- ActionController::Base.relative_url_root = orig_relative_url_root
end
def test_only_path