Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb
index 796c068..61639be 100644
--- a/railties/lib/rails/application.rb
+++ b/railties/lib/rails/application.rb
@@ -94,6 +94,10 @@ module Rails
super.run_load_hooks!
end
+ def create(initial_variable_values = {}, &block)
+ new(initial_variable_values, &block).run_load_hooks!
+ end
+
# Makes the +new+ method public.
#
# Note that Rails::Application inherits from Rails::Engine, which
diff --git a/railties/test/application/multiple_applications_test.rb b/railties/test/application/multiple_applications_test.rb
index 98707d2..9ebf163 100644
--- a/railties/test/application/multiple_applications_test.rb
+++ b/railties/test/application/multiple_applications_test.rb
@@ -36,23 +36,23 @@ module ApplicationTests
end
def test_initialization_of_application_with_previous_config
- application1 = AppTemplate::Application.new(config: Rails.application.config)
- application2 = AppTemplate::Application.new
+ application1 = AppTemplate::Application.create(config: Rails.application.config)
+ application2 = AppTemplate::Application.create
assert_equal Rails.application.config, application1.config, "Creating a new application while setting an initial config should result in the same config"
assert_not_equal Rails.application.config, application2.config, "New applications without setting an initial config should not have the same config"
end
def test_initialization_of_application_with_previous_railties
- application1 = AppTemplate::Application.new(railties: Rails.application.railties)
- application2 = AppTemplate::Application.new
+ application1 = AppTemplate::Application.create(railties: Rails.application.railties)
+ application2 = AppTemplate::Application.create
assert_equal Rails.application.railties, application1.railties
assert_not_equal Rails.application.railties, application2.railties
end
def test_initialize_new_application_with_all_previous_initialization_variables
- application1 = AppTemplate::Application.new(
+ application1 = AppTemplate::Application.create(
config: Rails.application.config,
railties: Rails.application.railties,
routes_reloader: Rails.application.routes_reloader,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment