diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-26 12:14:48 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-26 12:16:47 +0100 |
commit | db99324a89a2a681c6f6b0957dac7a309bfca574 (patch) | |
tree | 27884c07d6ba447fc26b61fd250cc8b6110d467f /railties | |
parent | c5b652f3d25ef92ae0f67551464fb03bda6aeb4f (diff) | |
download | rails-db99324a89a2a681c6f6b0957dac7a309bfca574.tar.gz rails-db99324a89a2a681c6f6b0957dac7a309bfca574.tar.bz2 rails-db99324a89a2a681c6f6b0957dac7a309bfca574.zip |
Ensure calling a method in Rails::Application does not instantiate a void application.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/application.rb | 6 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 7 |
2 files changed, 10 insertions, 3 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index b7e5eb7a1d..eba49e1520 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -16,10 +16,10 @@ module Rails alias :configure :class_eval def instance - if instance_of?(Rails::Application) - Rails.application.instance + if self == Rails::Application + Rails.application else - @instance ||= new + @@instance ||= new end end diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 6968e87986..d3ba54a668 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -19,6 +19,13 @@ module ApplicationTests FileUtils.rm_rf("#{app_path}/config/environments") end + test "Rails::Application.instance is nil until app is initialized" do + require 'rails' + assert_nil Rails::Application.instance + require "#{app_path}/config/environment" + assert_equal AppTemplate::Application.instance, Rails::Application.instance + end + test "the application root is set correctly" do require "#{app_path}/config/environment" assert_equal Pathname.new(app_path), Rails.application.root |