Skip to content

Commit

Permalink
Merge pull request rails#7474 from steveklabnik/backport_89ebd28
Browse files Browse the repository at this point in the history
Backport 89ebd28 to 3-2-stable
  • Loading branch information
drogus committed Aug 29, 2012
2 parents 58d35f6 + 728e925 commit f84fc39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/testing/test_request.rb
Expand Up @@ -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'
Expand Down
7 changes: 7 additions & 0 deletions actionpack/test/dispatch/test_request_test.rb
Expand Up @@ -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"))
Expand Down

0 comments on commit f84fc39

Please sign in to comment.