Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…void application.
  • Loading branch information...
commit db99324a89a2a681c6f6b0957dac7a309bfca574 1 parent c5b652f
@josevalim josevalim authored
View
6 railties/lib/rails/application.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
View
7 railties/test/application/configuration_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.