diff options
author | Marc-Andre Lafortune <github@marc-andre.ca> | 2012-05-21 15:24:18 -0400 |
---|---|---|
committer | Marc-Andre Lafortune <github@marc-andre.ca> | 2012-05-21 15:24:18 -0400 |
commit | 89ebd28d4ec899d840bddbef7711983a1ae2a162 (patch) | |
tree | 876ee3f8222ed46500069a27b46938936c037416 | |
parent | 776ea1090fb9ba4353035d4983cf1926a67b3294 (diff) | |
download | rails-89ebd28d4ec899d840bddbef7711983a1ae2a162.tar.gz rails-89ebd28d4ec899d840bddbef7711983a1ae2a162.tar.bz2 rails-89ebd28d4ec899d840bddbef7711983a1ae2a162.zip |
Fix bug when Rails.application is defined but is nil. See #881
-rw-r--r-- | actionpack/lib/action_dispatch/testing/test_request.rb | 2 | ||||
-rw-r--r-- | actionpack/test/dispatch/test_request_test.rb | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/testing/test_request.rb b/actionpack/lib/action_dispatch/testing/test_request.rb index d04be2099c..a86b510719 100644 --- a/actionpack/lib/action_dispatch/testing/test_request.rb +++ b/actionpack/lib/action_dispatch/testing/test_request.rb @@ -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' diff --git a/actionpack/test/dispatch/test_request_test.rb b/actionpack/test/dispatch/test_request_test.rb index 4ee1d61146..6047631ba3 100644 --- a/actionpack/test/dispatch/test_request_test.rb +++ b/actionpack/test/dispatch/test_request_test.rb @@ -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")) |