diff options
author | eileencodes <eileencodes@gmail.com> | 2016-11-07 15:46:56 -0500 |
---|---|---|
committer | eileencodes <eileencodes@gmail.com> | 2017-02-20 15:07:33 -0500 |
commit | 1db7a5c285eeb61acc998c0c27788a61bd948d5c (patch) | |
tree | c41e81e4c078bbe596f37ecdfc028fabd462e803 | |
parent | 5bf0aa6745db27c45c0778f9f6e9046f9ee9fb94 (diff) | |
download | rails-1db7a5c285eeb61acc998c0c27788a61bd948d5c.tar.gz rails-1db7a5c285eeb61acc998c0c27788a61bd948d5c.tar.bz2 rails-1db7a5c285eeb61acc998c0c27788a61bd948d5c.zip |
Don't load ActionSystemTest in production
By moving to the TestUnit Railtie, and doing the file requirement
inside the onload call we can avoid loading ActionSystemTest in
production and load it in the test env.
This is important for performance reasons - loading up unnecessary files
and object is expensive, especially when they should never be used in
production.
-rw-r--r-- | actionsystemtest/lib/action_system_test.rb | 2 | ||||
-rw-r--r-- | actionsystemtest/lib/action_system_test/railtie.rb | 17 | ||||
-rw-r--r-- | railties/lib/rails/all.rb | 1 | ||||
-rw-r--r-- | railties/lib/rails/test_unit/railtie.rb | 12 |
4 files changed, 12 insertions, 20 deletions
diff --git a/actionsystemtest/lib/action_system_test.rb b/actionsystemtest/lib/action_system_test.rb index 4a80e34695..18b992a3ca 100644 --- a/actionsystemtest/lib/action_system_test.rb +++ b/actionsystemtest/lib/action_system_test.rb @@ -50,8 +50,6 @@ require "action_system_test/driver_adapter" module ActionSystemTest include ActionSystemTest::TestHelper include ActionSystemTest::DriverAdapter - - ActiveSupport.run_load_hooks(:system_testing, self) end class ActionSystemTestCase < ActionDispatch::IntegrationTest diff --git a/actionsystemtest/lib/action_system_test/railtie.rb b/actionsystemtest/lib/action_system_test/railtie.rb deleted file mode 100644 index 6f4fe1b993..0000000000 --- a/actionsystemtest/lib/action_system_test/railtie.rb +++ /dev/null @@ -1,17 +0,0 @@ -require "action_system_test" - -module ActionSystemTest - # = System Testing Railtie - class Railtie < Rails::Railtie # :nodoc: - config.system_testing = ActiveSupport::OrderedOptions.new - - initializer "system_testing.set_configs" do |app| - options = app.config.system_testing - options.driver ||= ActionSystemTest.default_driver - - ActiveSupport.on_load(:system_testing) do - options.each { |k,v| send("#{k}=", v) } - end - end - end -end diff --git a/railties/lib/rails/all.rb b/railties/lib/rails/all.rb index 2cc33ceb5e..7606ea0e46 100644 --- a/railties/lib/rails/all.rb +++ b/railties/lib/rails/all.rb @@ -9,7 +9,6 @@ require "rails" action_cable/engine rails/test_unit/railtie sprockets/railtie - action_system_test/railtie ).each do |railtie| begin require railtie diff --git a/railties/lib/rails/test_unit/railtie.rb b/railties/lib/rails/test_unit/railtie.rb index d3f52e8008..694c8d92b1 100644 --- a/railties/lib/rails/test_unit/railtie.rb +++ b/railties/lib/rails/test_unit/railtie.rb @@ -20,6 +20,18 @@ module Rails } end + config.system_testing = ActiveSupport::OrderedOptions.new + + initializer "system_testing.set_configs" do |app| + ActiveSupport.on_load(:active_support_test_case) do + require "action_system_test" + + options = app.config.system_testing + options.driver ||= ActionSystemTest.default_driver + options.each { |k, v| ActionSystemTest.send("#{k}=", v) } + end + end + rake_tasks do load "rails/test_unit/testing.rake" end |