aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2016-08-14 19:01:29 -0400
committerGitHub <noreply@github.com>2016-08-14 19:01:29 -0400
commite7910af8689ec7e3116c449fe742ed38d2f02992 (patch)
tree7d86b3a5a54d2050a9c63e305f97f127a7945d6c
parentb6c0bc9c8a6a6dc86b315566e3ab52acc1a5377d (diff)
parent407e43866e2e5bb91eb7e3de2f9bed57cd25abc2 (diff)
downloadrails-e7910af8689ec7e3116c449fe742ed38d2f02992.tar.gz
rails-e7910af8689ec7e3116c449fe742ed38d2f02992.tar.bz2
rails-e7910af8689ec7e3116c449fe742ed38d2f02992.zip
Merge pull request #26150 from kamipo/consolidate_ar_test_case_and_as_test_case
Consolidate `ActiveRecord::TestCase` and `ActiveSupport::TestCase` in AR test cases
-rw-r--r--activerecord/lib/active_record/fixtures.rb8
-rw-r--r--activerecord/test/cases/helper.rb17
-rw-r--r--activerecord/test/cases/test_case.rb16
3 files changed, 20 insertions, 21 deletions
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index 40a9aa2783..57592d368f 100644
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -14,7 +14,7 @@ module ActiveRecord
# \Fixtures are a way of organizing data that you want to test against; in short, sample data.
#
# They are stored in YAML files, one file per model, which are placed in the directory
- # appointed by <tt>ActiveSupport::TestCase.fixture_path=(path)</tt> (this is automatically
+ # appointed by <tt>ActiveRecord::TestCase.fixture_path=(path)</tt> (this is automatically
# configured for Rails, so you can just put your files in <tt><your-rails-app>/test/fixtures/</tt>).
# The fixture file ends with the +.yml+ file extension, for example:
# <tt><your-rails-app>/test/fixtures/web_sites.yml</tt>).
@@ -57,7 +57,7 @@ module ActiveRecord
#
# require 'test_helper'
#
- # class WebSiteTest < ActiveSupport::TestCase
+ # class WebSiteTest < ActiveRecord::TestCase
# test "web_site_count" do
# assert_equal 2, WebSite.count
# end
@@ -89,7 +89,7 @@ module ActiveRecord
# end
#
# In order to use these methods to access fixtured data within your testcases, you must specify one of the
- # following in your ActiveSupport::TestCase-derived class:
+ # following in your ActiveRecord::TestCase-derived class:
#
# - to fully enable instantiated fixtures (enable alternate methods #1 and #2 above)
# self.use_instantiated_fixtures = true
@@ -144,7 +144,7 @@ module ActiveRecord
# Test cases can use begin+rollback to isolate their changes to the database instead of having to
# delete+insert for every test case.
#
- # class FooTest < ActiveSupport::TestCase
+ # class FooTest < ActiveRecord::TestCase
# self.use_transactional_tests = true
#
# test "godzilla" do
diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb
index ebd4437a87..f1d69a215a 100644
--- a/activerecord/test/cases/helper.rb
+++ b/activerecord/test/cases/helper.rb
@@ -1,7 +1,5 @@
require "config"
-require "active_support/testing/autorun"
-require "active_support/testing/method_call_assertions"
require "stringio"
require "active_record"
@@ -134,21 +132,6 @@ def disable_extension!(extension, connection)
connection.reconnect!
end
-require "cases/validations_repair_helper"
-class ActiveSupport::TestCase
- include ActiveRecord::TestFixtures
- include ActiveRecord::ValidationsRepairHelper
- include ActiveSupport::Testing::MethodCallAssertions
-
- self.fixture_path = FIXTURES_ROOT
- self.use_instantiated_fixtures = false
- self.use_transactional_tests = true
-
- def create_fixtures(*fixture_set_names, &block)
- ActiveRecord::FixtureSet.create_fixtures(ActiveSupport::TestCase.fixture_path, fixture_set_names, fixture_class_names, &block)
- end
-end
-
def load_schema
# silence verbose schema loading
original_stdout = $stdout
diff --git a/activerecord/test/cases/test_case.rb b/activerecord/test/cases/test_case.rb
index b4f5226f2b..7e8746b4f7 100644
--- a/activerecord/test/cases/test_case.rb
+++ b/activerecord/test/cases/test_case.rb
@@ -1,13 +1,29 @@
require "active_support/test_case"
+require "active_support/testing/autorun"
+require "active_support/testing/method_call_assertions"
require "active_support/testing/stream"
require "active_support/core_ext/regexp"
+require "active_record/fixtures"
+
+require "cases/validations_repair_helper"
module ActiveRecord
# = Active Record Test Case
#
# Defines some test assertions to test against SQL queries.
class TestCase < ActiveSupport::TestCase #:nodoc:
+ include ActiveSupport::Testing::MethodCallAssertions
include ActiveSupport::Testing::Stream
+ include ActiveRecord::TestFixtures
+ include ActiveRecord::ValidationsRepairHelper
+
+ self.fixture_path = FIXTURES_ROOT
+ self.use_instantiated_fixtures = false
+ self.use_transactional_tests = true
+
+ def create_fixtures(*fixture_set_names, &block)
+ ActiveRecord::FixtureSet.create_fixtures(ActiveRecord::TestCase.fixture_path, fixture_set_names, fixture_class_names, &block)
+ end
def teardown
SQLCounter.clear_log