Permalink
Browse files

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

  • Loading branch information...
1 parent 153df92 commit abeb0ff2cc99967b852c509e5d3bd186fa8a184c @drogus drogus committed Jul 22, 2010
Showing with 7 additions and 0 deletions.
  1. +2 −0 railties/lib/rails/application.rb
  2. +5 −0 railties/test/application/loading_test.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
@@ -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!

0 comments on commit abeb0ff

Please sign in to comment.