1
0
Fork 0
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:
Carlos Antonio da Silva 2012-05-21 15:34:51 -07:00
commit c5fc159949
2 changed files with 8 additions and 1 deletions

View file

@ -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'

View file

@ -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"))