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:
parent
776ea1090f
commit
89ebd28d4e
2 changed files with 8 additions and 1 deletions
|
@ -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'
|
||||||
|
|
|
@ -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"))
|
||||||
|
|
Loading…
Reference in a new issue