aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2011-04-06 16:37:55 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2011-04-06 16:37:55 -0300
commit0e4748cd415660eb91e63d50aa15cdd027c612dd (patch)
tree8e7106db762d8150f4e6c56289be99ccc5302b81
parent0c5aded0922f80bd1a31c7d2a3974469a18160a8 (diff)
downloadrails-0e4748cd415660eb91e63d50aa15cdd027c612dd.tar.gz
rails-0e4748cd415660eb91e63d50aa15cdd027c612dd.tar.bz2
rails-0e4748cd415660eb91e63d50aa15cdd027c612dd.zip
Make process reuse the env var passed as argument
-rw-r--r--actionpack/lib/action_dispatch/testing/integration.rb9
-rw-r--r--actionpack/test/controller/integration_test.rb8
2 files changed, 12 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb
index 4706112a06..9b2f534457 100644
--- a/actionpack/lib/action_dispatch/testing/integration.rb
+++ b/actionpack/lib/action_dispatch/testing/integration.rb
@@ -243,7 +243,8 @@ module ActionDispatch
end
# Performs the actual request.
- def process(method, path, parameters = nil, rack_environment = nil)
+ def process(method, path, parameters = nil, env = nil)
+ env ||= {}
if path =~ %r{://}
location = URI.parse(path)
https! URI::HTTPS === location if location.scheme
@@ -259,7 +260,7 @@ module ActionDispatch
hostname, port = host.split(':')
- env = {
+ default_env = {
:method => method,
:params => parameters,
@@ -277,9 +278,7 @@ module ActionDispatch
session = Rack::Test::Session.new(_mock_session)
- (rack_environment || {}).each do |key, value|
- env[key] = value
- end
+ env.reverse_merge!(default_env)
# NOTE: rack-test v0.5 doesn't build a default uri correctly
# Make sure requested path is always a full uri
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb
index f0d62b0b13..01dc2f2091 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -521,4 +521,12 @@ class ApplicationIntegrationTest < ActionDispatch::IntegrationTest
get '/foo'
assert_raise(NameError) { missing_path }
end
+
+ test "process reuse the env we pass as argument" do
+ env = { :SERVER_NAME => 'server', 'action_dispatch.custom' => 'custom' }
+ get '/foo', nil, env
+ assert_equal :get, env[:method]
+ assert_equal 'server', env[:SERVER_NAME]
+ assert_equal 'custom', env['action_dispatch.custom']
+ end
end