diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-07-03 17:37:47 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-07-03 17:37:47 -0700 |
commit | 142d50e52e5d33f061fa2909463c49e17dd4ddd1 (patch) | |
tree | 9ff0584e8cbbab8d7a7bff6335ae91e490481919 /actionpack | |
parent | 5ee27630f79588f9e97c4bd1c55184b9f3616d25 (diff) | |
download | rails-142d50e52e5d33f061fa2909463c49e17dd4ddd1.tar.gz rails-142d50e52e5d33f061fa2909463c49e17dd4ddd1.tar.bz2 rails-142d50e52e5d33f061fa2909463c49e17dd4ddd1.zip |
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.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 11 | ||||
-rw-r--r-- | 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 |