Skip to content

Commit

Permalink
Ensure that Rails.application.initialize! is called only once
Browse files Browse the repository at this point in the history
  • Loading branch information
drogus committed Jul 25, 2010
1 parent 300cfc3 commit 12d6153
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions railties/lib/rails/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions railties/test/application/loading_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down

0 comments on commit 12d6153

Please sign in to comment.