Skip to content
Browse files

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.
  • Loading branch information...
1 parent 5ee2763 commit 142d50e52e5d33f061fa2909463c49e17dd4ddd1 @tenderlove tenderlove committed Jul 3, 2012
View
11 actionpack/lib/action_controller/test_case.rb
@@ -143,6 +143,9 @@ def assert_template(options = {}, message = nil)
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 @@ def recycle!
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 @@ def setup_controller_request_and_response
@controller ||= klass.new rescue nil
end
- @request.env.delete('PATH_INFO')
-
if defined?(@controller) && @controller
@controller.request = @request
@controller.params = {}
View
8 actionpack/lib/action_dispatch/testing/test_request.rb
@@ -12,7 +12,7 @@ def self.new(env = {})
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 @@ def accept=(mime_types)
def cookies
@cookies ||= {}.with_indifferent_access
end
+
+ private
+
+ def default_env
+ DEFAULT_ENV
+ end
end
end

0 comments on commit 142d50e

Please sign in to comment.
Something went wrong with that request. Please try again.