mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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.
This commit is contained in:
parent
5ee27630f7
commit
142d50e52e
2 changed files with 16 additions and 3 deletions
|
@ -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 = {}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue