mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Ensure that Rails.application.initialize! is called only once
This commit is contained in:
parent
153df92f9f
commit
abeb0ff2cc
2 changed files with 7 additions and 0 deletions
|
@ -95,7 +95,9 @@ module Rails
|
|||
end
|
||||
|
||||
def initialize!
|
||||
raise "Application has been already initialized." if @initialized
|
||||
run_initializers(self)
|
||||
@initialized = true
|
||||
self
|
||||
end
|
||||
|
||||
|
|
|
@ -89,6 +89,11 @@ class LoadingTest < Test::Unit::TestCase
|
|||
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!
|
||||
|
|
Loading…
Reference in a new issue