mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #6429 from marcandre/fix_test_request
Fix bug when Rails.application is defined but is nil. See #881
This commit is contained in:
commit
c5fc159949
2 changed files with 8 additions and 1 deletions
|
@ -11,7 +11,7 @@ module ActionDispatch
|
|||
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"))
|
||||
|
|
Loading…
Reference in a new issue