Permalink
Browse files

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.
  • Loading branch information...
eileencodes committed Nov 7, 2016
1 parent 5bf0aa6 commit 1db7a5c285eeb61acc998c0c27788a61bd948d5c
@@ -50,8 +50,6 @@
module ActionSystemTest
include ActionSystemTest::TestHelper
include ActionSystemTest::DriverAdapter
ActiveSupport.run_load_hooks(:system_testing, self)
end
class ActionSystemTestCase < ActionDispatch::IntegrationTest
@@ -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
@@ -9,7 +9,6 @@
action_cable/engine
rails/test_unit/railtie
sprockets/railtie
action_system_test/railtie
).each do |railtie|
begin
require railtie
@@ -20,6 +20,18 @@ class TestUnitRailtie < Rails::Railtie
}
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

0 comments on commit 1db7a5c

Please sign in to comment.