Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ensure that Rails.application.initialize! is called only once

  • Loading branch information...
commit abeb0ff2cc99967b852c509e5d3bd186fa8a184c 1 parent 153df92
@drogus drogus authored
View
2  railties/lib/rails/application.rb
@@ -95,7 +95,9 @@ def reload_routes!
end
def initialize!
+ raise "Application has been already initialized." if @initialized
run_initializers(self)
+ @initialized = true
self
end
View
5 railties/test/application/loading_test.rb
@@ -89,6 +89,11 @@ class Post < ActiveRecord::Base
assert_equal [], ActiveRecord::Base.descendants
end
+ test "initialize_cant_be_called_twice" do
+ require "#{app_path}/config/environment"
+ assert_raise(RuntimeError) { ::AppTemplate::Application.initialize! }
+ end
+
protected
def setup_ar!
Please sign in to comment.
Something went wrong with that request. Please try again.