From b6f935bbf9b8470b370ea613dc61218849aabf89 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 21 Oct 2016 14:44:17 -0700 Subject: Use `on_load` to trigger commandline processing code We need to use on_load so that plugins will get the same functionality --- railties/lib/rails/commands/test/test_command.rb | 5 ----- railties/lib/rails/test_unit/railtie.rb | 8 ++++++++ 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/commands/test/test_command.rb b/railties/lib/rails/commands/test/test_command.rb index e97b9cbbba..1b2e3af9cc 100644 --- a/railties/lib/rails/commands/test/test_command.rb +++ b/railties/lib/rails/commands/test/test_command.rb @@ -1,6 +1,5 @@ require "rails/command" require "rails/test_unit/minitest_plugin" -require "rails/test_unit/line_filtering" module Rails module Command @@ -12,10 +11,6 @@ module Rails def perform(*) $LOAD_PATH << Rails::Command.root.join("test") - # Add test line filtering support for running test by line number - # via the command line. - ActiveSupport::TestCase.extend Rails::LineFiltering - Minitest.run_via[:rails] = true require "active_support/testing/autorun" diff --git a/railties/lib/rails/test_unit/railtie.rb b/railties/lib/rails/test_unit/railtie.rb index ec91673e40..746120e6a1 100644 --- a/railties/lib/rails/test_unit/railtie.rb +++ b/railties/lib/rails/test_unit/railtie.rb @@ -1,3 +1,5 @@ +require "rails/test_unit/line_filtering" + if defined?(Rake.application) && Rake.application.top_level_tasks.grep(/^(default$|test(:|$))/).any? ENV["RAILS_ENV"] ||= "test" end @@ -11,6 +13,12 @@ module Rails c.integration_tool :test_unit end + initializer "test_unit.line_filtering" do + ActiveSupport.on_load(:active_support_test_case) { + ActiveSupport::TestCase.extend Rails::LineFiltering + } + end + rake_tasks do load "rails/test_unit/testing.rake" end -- cgit v1.2.3