1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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

This commit is contained in:
Marc-Andre Lafortune 2012-05-21 15:24:18 -04:00
parent 776ea1090f
commit 89ebd28d4e
2 changed files with 8 additions and 1 deletions

View file

@ -11,7 +11,7 @@ module ActionDispatch
end end
def initialize(env = {}) 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)) super(DEFAULT_ENV.merge(env))
self.host = 'test.host' self.host = 'test.host'

View file

@ -55,6 +55,13 @@ class TestRequestTest < ActiveSupport::TestCase
assert_cookies({"user_name" => "david"}, req.cookie_jar) assert_cookies({"user_name" => "david"}, req.cookie_jar)
end 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 private
def assert_cookies(expected, cookie_jar) def assert_cookies(expected, cookie_jar)
assert_equal(expected, cookie_jar.instance_variable_get("@cookies")) assert_equal(expected, cookie_jar.instance_variable_get("@cookies"))