Permalink
Browse files

Ensure calling a method in Rails::Application does not instantiate a …

…void application.
  • Loading branch information...
josevalim committed Jan 26, 2010
1 parent c5b652f commit db99324a89a2a681c6f6b0957dac7a309bfca574
Showing with 10 additions and 3 deletions.
  1. +3 −3 railties/lib/rails/application.rb
  2. +7 −0 railties/test/application/configuration_test.rb
@@ -16,10 +16,10 @@ class << self
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
@@ -19,6 +19,13 @@ def setup
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

0 comments on commit db99324

Please sign in to comment.