diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-05-19 23:48:05 +0200 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-05-19 23:50:03 +0200 |
commit | 4a6f4b92ad2f48dc7906d223fe4708d36624bd50 (patch) | |
tree | 704441a195da4ac26c513e55927195a340459e99 /actionpack/lib/action_controller | |
parent | 0bdef30f35501953ffdcb34f1c8d3a1e23f9434d (diff) | |
download | rails-4a6f4b92ad2f48dc7906d223fe4708d36624bd50.tar.gz rails-4a6f4b92ad2f48dc7906d223fe4708d36624bd50.tar.bz2 rails-4a6f4b92ad2f48dc7906d223fe4708d36624bd50.zip |
Change integration test helpers to accept Rack environment instead of just HTTP Headers.
Before : get '/path', {}, 'Accept' => 'text/javascript'
After : get '/path', {}, 'HTTP_ACCEPT' => 'text/javascript'
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/testing/integration.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/testing/integration.rb b/actionpack/lib/action_controller/testing/integration.rb index d6991ab4f5..a8e8f16d6c 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 |