Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #6429 from marcandre/fix_test_request

Fix bug when Rails.application is defined but is nil. See #881
  • Loading branch information...
commit c5fc159949f19708002ba801438ca5434192b074 2 parents 03886d8 + 89ebd28
@carlosantoniodasilva carlosantoniodasilva authored
View
2  actionpack/lib/action_dispatch/testing/test_request.rb
@@ -11,7 +11,7 @@ def self.new(env = {})
end
def initialize(env = {})
- env = Rails.application.env_config.merge(env) if defined?(Rails.application)
+ env = Rails.application.env_config.merge(env) if defined?(Rails.application) && Rails.application
super(DEFAULT_ENV.merge(env))
self.host = 'test.host'
View
7 actionpack/test/dispatch/test_request_test.rb
@@ -55,6 +55,13 @@ class TestRequestTest < ActiveSupport::TestCase
assert_cookies({"user_name" => "david"}, req.cookie_jar)
end
+ test "does not complain when Rails.application is nil" do
+ Rails.stubs(:application).returns(nil)
+ req = ActionDispatch::TestRequest.new
+
+ assert_equal false, req.env.empty?
+ end
+
private
def assert_cookies(expected, cookie_jar)
assert_equal(expected, cookie_jar.instance_variable_get("@cookies"))
Please sign in to comment.
Something went wrong with that request. Please try again.