aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/test_help.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/test_help.rb')
-rw-r--r--railties/lib/rails/test_help.rb45
1 files changed, 18 insertions, 27 deletions
diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb
index 8e290239bd..4e3ec184be 100644
--- a/railties/lib/rails/test_help.rb
+++ b/railties/lib/rails/test_help.rb
@@ -1,8 +1,9 @@
+# frozen_string_literal: true
+
# Make double-sure the RAILS_ENV is not set to production,
# so fixtures aren't loaded into that environment
abort("Abort testing: Your Rails environment is running in production mode!") if Rails.env.production?
-require "rails/test_unit/minitest_plugin"
require "active_support/test_case"
require "action_controller"
require "action_controller/test_case"
@@ -11,49 +12,39 @@ require "rails/generators/test_case"
require "active_support/testing/autorun"
-if defined?(Capybara) && defined?(Puma)
- require "action_dispatch/system_test_case"
-end
-
if defined?(ActiveRecord::Base)
- ActiveRecord::Migration.maintain_test_schema!
-
- module ActiveSupport
- class TestCase
- include ActiveRecord::TestFixtures
- self.fixture_path = "#{Rails.root}/test/fixtures/"
- self.file_fixture_path = fixture_path + "files"
- end
+ begin
+ ActiveRecord::Migration.maintain_test_schema!
+ rescue ActiveRecord::PendingMigrationError => e
+ puts e.to_s.strip
+ exit 1
end
- ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
+ ActiveSupport.on_load(:active_support_test_case) do
+ include ActiveRecord::TestDatabases
+ include ActiveRecord::TestFixtures
+
+ self.fixture_path = "#{Rails.root}/test/fixtures/"
+ self.file_fixture_path = fixture_path + "files"
+ end
- def create_fixtures(*fixture_set_names, &block)
- FixtureSet.create_fixtures(ActiveSupport::TestCase.fixture_path, fixture_set_names, {}, &block)
+ ActiveSupport.on_load(:action_dispatch_integration_test) do
+ self.fixture_path = ActiveSupport::TestCase.fixture_path
end
end
# :enddoc:
-class ActionController::TestCase
+ActiveSupport.on_load(:action_controller_test_case) do
def before_setup # :nodoc:
@routes = Rails.application.routes
super
end
end
-class ActionDispatch::IntegrationTest
+ActiveSupport.on_load(:action_dispatch_integration_test) do
def before_setup # :nodoc:
@routes = Rails.application.routes
super
end
end
-
-if defined?(Capybara) && defined?(Puma)
- class ActionDispatch::SystemTestCase
- def before_setup # :nodoc:
- @routes = Rails.application.routes
- super
- end
- end
-end