Skip to content
Browse files

Rails.initialized? can be called at any time without raising an excep…

…tion [Closes #2507]

Changes:

* `Rails.initialized=` has been removed
* `Rails.initialized?` and `Rails.application.initialized?` are now
* delegating to `MyApp::Application.initialized?`
  • Loading branch information...
1 parent 33164c8 commit 4882271f6bae7bc8d91caf36cc8f16c7e6969b7b @franckverrot committed
Showing with 15 additions and 5 deletions.
  1. +1 −5 railties/lib/rails.rb
  2. +4 −0 railties/lib/rails/application.rb
  3. +10 −0 railties/test/application/loading_test.rb
View
6 railties/lib/rails.rb
@@ -42,11 +42,7 @@ def initialize!
end
def initialized?
- @@initialized || false
- end
-
- def initialized=(initialized)
- @@initialized ||= initialized
+ application.initialized?
end
def logger
View
4 railties/lib/rails/application.rb
@@ -134,6 +134,10 @@ def initialize!(group=:default) #:nodoc:
self
end
+ def initialized?
+ @initialized
+ end
+
# Load the application and its railties tasks and invoke the registered hooks.
# Check <tt>Rails::Railtie.rake_tasks</tt> for more info.
def load_tasks(app=self)
View
10 railties/test/application/loading_test.rb
@@ -285,6 +285,16 @@ def show
assert_equal 'OK', last_response.body
end
+ def test_initialize_can_be_called_at_any_time
+ require "#{app_path}/config/application"
+
+ assert !Rails.initialized?
+ assert !AppTemplate::Application.initialized?
+ Rails.initialize!
+ assert Rails.initialized?
+ assert AppTemplate::Application.initialized?
+ end
+
protected
def setup_ar!

0 comments on commit 4882271

Please sign in to comment.
Something went wrong with that request. Please try again.