Created
May 19, 2009 21:45
-
-
Save lifo/114437 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/actionpack/lib/action_controller/testing/integration.rb b/actionpack/lib/action_controller/testing/integration.rb | |
index d6991ab..a8e8f16 100644 | |
--- a/actionpack/lib/action_controller/testing/integration.rb | |
+++ b/actionpack/lib/action_controller/testing/integration.rb | |
@@ -62,8 +62,8 @@ module ActionController | |
# with 'HTTP_' if not already. | |
def xml_http_request(request_method, path, parameters = nil, headers = nil) | |
headers ||= {} | |
- headers['X-Requested-With'] = 'XMLHttpRequest' | |
- headers['Accept'] ||= [Mime::JS, Mime::HTML, Mime::XML, 'text/xml', Mime::ALL].join(', ') | |
+ headers['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest' | |
+ headers['HTTP_ACCEPT'] ||= [Mime::JS, Mime::HTML, Mime::XML, 'text/xml', Mime::ALL].join(', ') | |
process(request_method, path, parameters, headers) | |
end | |
alias xhr :xml_http_request | |
@@ -228,7 +228,7 @@ module ActionController | |
private | |
# Performs the actual request. | |
- def process(method, path, parameters = nil, headers = nil) | |
+ def process(method, path, parameters = nil, rack_environment = nil) | |
if path =~ %r{://} | |
location = URI.parse(path) | |
https! URI::HTTPS === location if location.scheme | |
@@ -265,9 +265,7 @@ module ActionController | |
} | |
env = Rack::MockRequest.env_for(path, opts) | |
- (headers || {}).each do |key, value| | |
- key = key.to_s.upcase.gsub(/-/, "_") | |
- key = "HTTP_#{key}" unless env.has_key?(key) || key =~ /^HTTP_/ | |
+ (rack_environment || {}).each do |key, value| | |
env[key] = value | |
end | |
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb | |
index c616107..a2b3ad2 100644 | |
--- a/actionpack/test/controller/integration_test.rb | |
+++ b/actionpack/test/controller/integration_test.rb | |
@@ -123,8 +123,8 @@ class SessionTest < Test::Unit::TestCase | |
def test_xml_http_request_get | |
path = "/index"; params = "blah"; headers = {:location => 'blah'} | |
headers_after_xhr = headers.merge( | |
- "X-Requested-With" => "XMLHttpRequest", | |
- "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" | |
+ "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest", | |
+ "HTTP_ACCEPT" => "text/javascript, text/html, application/xml, text/xml, */*" | |
) | |
@session.expects(:process).with(:get,path,params,headers_after_xhr) | |
@session.xml_http_request(:get,path,params,headers) | |
@@ -133,8 +133,8 @@ class SessionTest < Test::Unit::TestCase | |
def test_xml_http_request_post | |
path = "/index"; params = "blah"; headers = {:location => 'blah'} | |
headers_after_xhr = headers.merge( | |
- "X-Requested-With" => "XMLHttpRequest", | |
- "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" | |
+ "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest", | |
+ "HTTP_ACCEPT" => "text/javascript, text/html, application/xml, text/xml, */*" | |
) | |
@session.expects(:process).with(:post,path,params,headers_after_xhr) | |
@session.xml_http_request(:post,path,params,headers) | |
@@ -143,8 +143,8 @@ class SessionTest < Test::Unit::TestCase | |
def test_xml_http_request_put | |
path = "/index"; params = "blah"; headers = {:location => 'blah'} | |
headers_after_xhr = headers.merge( | |
- "X-Requested-With" => "XMLHttpRequest", | |
- "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" | |
+ "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest", | |
+ "HTTP_ACCEPT" => "text/javascript, text/html, application/xml, text/xml, */*" | |
) | |
@session.expects(:process).with(:put,path,params,headers_after_xhr) | |
@session.xml_http_request(:put,path,params,headers) | |
@@ -153,8 +153,8 @@ class SessionTest < Test::Unit::TestCase | |
def test_xml_http_request_delete | |
path = "/index"; params = "blah"; headers = {:location => 'blah'} | |
headers_after_xhr = headers.merge( | |
- "X-Requested-With" => "XMLHttpRequest", | |
- "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" | |
+ "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest", | |
+ "HTTP_ACCEPT" => "text/javascript, text/html, application/xml, text/xml, */*" | |
) | |
@session.expects(:process).with(:delete,path,params,headers_after_xhr) | |
@session.xml_http_request(:delete,path,params,headers) | |
@@ -163,17 +163,17 @@ class SessionTest < Test::Unit::TestCase | |
def test_xml_http_request_head | |
path = "/index"; params = "blah"; headers = {:location => 'blah'} | |
headers_after_xhr = headers.merge( | |
- "X-Requested-With" => "XMLHttpRequest", | |
- "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" | |
+ "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest", | |
+ "HTTP_ACCEPT" => "text/javascript, text/html, application/xml, text/xml, */*" | |
) | |
@session.expects(:process).with(:head,path,params,headers_after_xhr) | |
@session.xml_http_request(:head,path,params,headers) | |
end | |
def test_xml_http_request_override_accept | |
- path = "/index"; params = "blah"; headers = {:location => 'blah', "Accept" => "application/xml"} | |
+ path = "/index"; params = "blah"; headers = {:location => 'blah', "HTTP_ACCEPT" => "application/xml"} | |
headers_after_xhr = headers.merge( | |
- "X-Requested-With" => "XMLHttpRequest" | |
+ "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest" | |
) | |
@session.expects(:process).with(:post,path,params,headers_after_xhr) | |
@session.xml_http_request(:post,path,params,headers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment