Permalink
Browse files

Fix bug when Rails.application is defined but is nil. See #881

  • Loading branch information...
1 parent 58d35f6 commit 728e925735d6532d1acd586f9dde30c499f91344 @marcandre marcandre committed with May 21, 2012
@@ -12,7 +12,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'
@@ -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"))

0 comments on commit 728e925

Please sign in to comment.