mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
add a new constructor that runs load hooks
This commit is contained in:
parent
2296989826
commit
8121eefc22
2 changed files with 9 additions and 5 deletions
|
@ -94,6 +94,10 @@ module Rails
|
||||||
super.run_load_hooks!
|
super.run_load_hooks!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create(initial_variable_values = {}, &block)
|
||||||
|
new(initial_variable_values, &block).run_load_hooks!
|
||||||
|
end
|
||||||
|
|
||||||
# Makes the +new+ method public.
|
# Makes the +new+ method public.
|
||||||
#
|
#
|
||||||
# Note that Rails::Application inherits from Rails::Engine, which
|
# Note that Rails::Application inherits from Rails::Engine, which
|
||||||
|
|
|
@ -36,23 +36,23 @@ module ApplicationTests
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_initialization_of_application_with_previous_config
|
def test_initialization_of_application_with_previous_config
|
||||||
application1 = AppTemplate::Application.new(config: Rails.application.config)
|
application1 = AppTemplate::Application.create(config: Rails.application.config)
|
||||||
application2 = AppTemplate::Application.new
|
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_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"
|
assert_not_equal Rails.application.config, application2.config, "New applications without setting an initial config should not have the same config"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_initialization_of_application_with_previous_railties
|
def test_initialization_of_application_with_previous_railties
|
||||||
application1 = AppTemplate::Application.new(railties: Rails.application.railties)
|
application1 = AppTemplate::Application.create(railties: Rails.application.railties)
|
||||||
application2 = AppTemplate::Application.new
|
application2 = AppTemplate::Application.create
|
||||||
|
|
||||||
assert_equal Rails.application.railties, application1.railties
|
assert_equal Rails.application.railties, application1.railties
|
||||||
assert_not_equal Rails.application.railties, application2.railties
|
assert_not_equal Rails.application.railties, application2.railties
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_initialize_new_application_with_all_previous_initialization_variables
|
def test_initialize_new_application_with_all_previous_initialization_variables
|
||||||
application1 = AppTemplate::Application.new(
|
application1 = AppTemplate::Application.create(
|
||||||
config: Rails.application.config,
|
config: Rails.application.config,
|
||||||
railties: Rails.application.railties,
|
railties: Rails.application.railties,
|
||||||
routes_reloader: Rails.application.routes_reloader,
|
routes_reloader: Rails.application.routes_reloader,
|
||||||
|
|
Loading…
Reference in a new issue