From 142d50e52e5d33f061fa2909463c49e17dd4ddd1 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 3 Jul 2012 17:37:47 -0700 Subject: make the default environment have actual defaults instead of deleting keys on every instantiation, create defaults we actually use. eventually we can pass an environment in to the request, and create a new req / res object on each call. --- actionpack/lib/action_controller/test_case.rb | 11 +++++++++-- actionpack/lib/action_dispatch/testing/test_request.rb | 8 +++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 2ac9ce2877..1f5b8e46a2 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -143,6 +143,9 @@ module ActionController end class TestRequest < ActionDispatch::TestRequest #:nodoc: + DEFAULT_ENV = ActionDispatch::TestRequest::DEFAULT_ENV.dup + DEFAULT_ENV.delete 'PATH_INFO' + def initialize(env = {}) super @@ -207,6 +210,12 @@ module ActionController cookie_jar.update(@set_cookies) cookie_jar.recycle! end + + private + + def default_env + DEFAULT_ENV + end end class TestResponse < ActionDispatch::TestResponse @@ -518,8 +527,6 @@ module ActionController @controller ||= klass.new rescue nil end - @request.env.delete('PATH_INFO') - if defined?(@controller) && @controller @controller.request = @request @controller.params = {} diff --git a/actionpack/lib/action_dispatch/testing/test_request.rb b/actionpack/lib/action_dispatch/testing/test_request.rb index a86b510719..639ae6f398 100644 --- a/actionpack/lib/action_dispatch/testing/test_request.rb +++ b/actionpack/lib/action_dispatch/testing/test_request.rb @@ -12,7 +12,7 @@ module ActionDispatch def initialize(env = {}) env = Rails.application.env_config.merge(env) if defined?(Rails.application) && Rails.application - super(DEFAULT_ENV.merge(env)) + super(default_env.merge(env)) self.host = 'test.host' self.remote_addr = '0.0.0.0' @@ -69,5 +69,11 @@ module ActionDispatch def cookies @cookies ||= {}.with_indifferent_access end + + private + + def default_env + DEFAULT_ENV + end end end -- cgit v1.2.3