aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile3
-rw-r--r--Gemfile.lock10
-rw-r--r--actionmailer/test/base_test.rb5
-rw-r--r--activerecord/test/cases/adapters/postgresql/hstore_test.rb8
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb3
-rw-r--r--activerecord/test/cases/autosave_association_test.rb4
-rw-r--r--activerecord/test/cases/fixtures_test.rb3
-rw-r--r--activerecord/test/cases/persistence_test.rb28
-rw-r--r--activerecord/test/cases/primary_keys_test.rb14
-rw-r--r--activerecord/test/cases/query_cache_test.rb2
-rw-r--r--activerecord/test/cases/reload_models_test.rb4
-rw-r--r--activerecord/test/cases/scoping/default_scoping_test.rb4
-rw-r--r--activesupport/test/current_attributes_test.rb9
-rw-r--r--railties/test/application/test_test.rb2
14 files changed, 52 insertions, 47 deletions
diff --git a/Gemfile b/Gemfile
index 2a1b9fa7ef..0106d3298a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -94,8 +94,7 @@ local_gemfile = File.expand_path(".Gemfile", __dir__)
instance_eval File.read local_gemfile if File.exist? local_gemfile
group :test do
- # FIX: Our test suite isn't ready to run in random order yet.
- gem "minitest", "< 5.3.4"
+ gem 'minitest-bisect'
platforms :mri do
gem "stackprof"
diff --git a/Gemfile.lock b/Gemfile.lock
index d08ddaf1b4..13b44b6bc1 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -215,7 +215,12 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
- minitest (5.3.3)
+ minitest (5.10.1)
+ minitest-bisect (1.4.0)
+ minitest-server (~> 1.0)
+ path_expander (~> 1.0)
+ minitest-server (1.0.4)
+ minitest (~> 5.0)
mocha (0.14.0)
metaclass (~> 0.0.1)
mono_logger (1.1.0)
@@ -235,6 +240,7 @@ GEM
parallel (1.11.2)
parser (2.4.0.0)
ast (~> 2.2)
+ path_expander (1.0.1)
pg (0.19.0)
pg (0.19.0-x64-mingw32)
pg (0.19.0-x86-mingw32)
@@ -399,7 +405,7 @@ DEPENDENCIES
kindlerb (~> 1.2.0)
libxml-ruby
listen (>= 3.0.5, < 3.2)
- minitest (< 5.3.4)
+ minitest-bisect
mocha (~> 0.14)
mysql2 (>= 0.4.4)
nokogiri (>= 1.6.8)
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb
index ebb97078e6..af1c2f44a5 100644
--- a/actionmailer/test/base_test.rb
+++ b/actionmailer/test/base_test.rb
@@ -979,8 +979,7 @@ class BasePreviewTest < ActiveSupport::TestCase
test "has access to params" do
params = { name: "World" }
- assert_called_with(BaseMailer, :welcome, [params]) do
- BaseMailerPreview.call(:welcome, params)
- end
+ message = BaseMailerPreview.call(:welcome, params)
+ assert_equal "World", message["name"].decoded
end
end
diff --git a/activerecord/test/cases/adapters/postgresql/hstore_test.rb b/activerecord/test/cases/adapters/postgresql/hstore_test.rb
index f9cce10fb8..4d650bd431 100644
--- a/activerecord/test/cases/adapters/postgresql/hstore_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/hstore_test.rb
@@ -19,12 +19,7 @@ if ActiveRecord::Base.connection.supports_extensions?
def setup
@connection = ActiveRecord::Base.connection
- unless @connection.extension_enabled?("hstore")
- @connection.enable_extension "hstore"
- @connection.commit_db_transaction
- end
-
- @connection.reconnect!
+ enable_extension!("hstore", @connection)
@connection.transaction do
@connection.create_table("hstores") do |t|
@@ -40,6 +35,7 @@ if ActiveRecord::Base.connection.supports_extensions?
teardown do
@connection.drop_table "hstores", if_exists: true
+ disable_extension!("hstore", @connection)
end
def test_hstore_included_in_extensions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index 590d3642bd..6102f98682 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -456,7 +456,10 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
end
def test_create_resets_cached_counters
+ Reader.delete_all
+
person = Person.create!(first_name: "tenderlove")
+
post = Post.first
assert_equal [], person.readers
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb
index 2203aa1788..f72a9520e0 100644
--- a/activerecord/test/cases/autosave_association_test.rb
+++ b/activerecord/test/cases/autosave_association_test.rb
@@ -1370,7 +1370,7 @@ module AutosaveAssociationOnACollectionAssociationTests
@pirate.send(@association_name).each_with_index { |child, i| child.name = new_names[i] }
@pirate.save
- assert_equal new_names, @pirate.reload.send(@association_name).map(&:name)
+ assert_equal new_names.sort, @pirate.reload.send(@association_name).map(&:name).sort
end
def test_should_automatically_save_bang_the_associated_models
@@ -1378,7 +1378,7 @@ module AutosaveAssociationOnACollectionAssociationTests
@pirate.send(@association_name).each_with_index { |child, i| child.name = new_names[i] }
@pirate.save!
- assert_equal new_names, @pirate.reload.send(@association_name).map(&:name)
+ assert_equal new_names.sort, @pirate.reload.send(@association_name).map(&:name).sort
end
def test_should_update_children_when_autosave_is_true_and_parent_is_new_but_child_is_not
diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb
index a0a6d3c7ef..e651f63c7e 100644
--- a/activerecord/test/cases/fixtures_test.rb
+++ b/activerecord/test/cases/fixtures_test.rb
@@ -365,6 +365,7 @@ if Account.connection.respond_to?(:reset_pk_sequence!)
class FixturesResetPkSequenceTest < ActiveRecord::TestCase
fixtures :accounts
fixtures :companies
+ self.use_transactional_tests = false
def setup
@instances = [Account.new(credit_limit: 50), Company.new(name: "RoR Consulting"), Course.new(name: "Test")]
@@ -809,6 +810,8 @@ class FasterFixturesTest < ActiveRecord::TestCase
end
class FoxyFixturesTest < ActiveRecord::TestCase
+ # Set to false to blow away fixtures cache and ensure our fixtures are loaded
+ self.use_transactional_tests = false
fixtures :parrots, :parrots_pirates, :pirates, :treasures, :mateys, :ships, :computers,
:developers, :"admin/accounts", :"admin/users", :live_parrots, :dead_parrots, :books
diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb
index 5895c51714..e9df570176 100644
--- a/activerecord/test/cases/persistence_test.rb
+++ b/activerecord/test/cases/persistence_test.rb
@@ -993,33 +993,19 @@ class PersistenceTest < ActiveRecord::TestCase
end
class SaveTest < ActiveRecord::TestCase
- self.use_transactional_tests = false
-
def test_save_touch_false
- widget = Class.new(ActiveRecord::Base) do
- connection.create_table :widgets, force: true do |t|
- t.string :name
- t.timestamps null: false
- end
-
- self.table_name = :widgets
- end
-
- instance = widget.create!(
+ pet = Pet.create!(
name: "Bob",
created_at: 1.day.ago,
updated_at: 1.day.ago)
- created_at = instance.created_at
- updated_at = instance.updated_at
+ created_at = pet.created_at
+ updated_at = pet.updated_at
- instance.name = "Barb"
- instance.save!(touch: false)
- assert_equal instance.created_at, created_at
- assert_equal instance.updated_at, updated_at
- ensure
- ActiveRecord::Base.connection.drop_table widget.table_name
- widget.reset_column_information
+ pet.name = "Barb"
+ pet.save!(touch: false)
+ assert_equal pet.created_at, created_at
+ assert_equal pet.updated_at, updated_at
end
end
diff --git a/activerecord/test/cases/primary_keys_test.rb b/activerecord/test/cases/primary_keys_test.rb
index 5ded619716..80cbfdba06 100644
--- a/activerecord/test/cases/primary_keys_test.rb
+++ b/activerecord/test/cases/primary_keys_test.rb
@@ -311,7 +311,7 @@ class CompositePrimaryKeyTest < ActiveRecord::TestCase
def setup
@connection = ActiveRecord::Base.connection
@connection.schema_cache.clear!
- @connection.create_table(:barcodes, primary_key: ["region", "code"], force: true) do |t|
+ @connection.create_table(:uber_barcodes, primary_key: ["region", "code"], force: true) do |t|
t.string :region
t.integer :code
end
@@ -322,11 +322,11 @@ class CompositePrimaryKeyTest < ActiveRecord::TestCase
end
def teardown
- @connection.drop_table(:barcodes, if_exists: true)
+ @connection.drop_table(:uber_barcodes, if_exists: true)
end
def test_composite_primary_key
- assert_equal ["region", "code"], @connection.primary_keys("barcodes")
+ assert_equal ["region", "code"], @connection.primary_keys("uber_barcodes")
end
def test_composite_primary_key_out_of_order
@@ -337,7 +337,7 @@ class CompositePrimaryKeyTest < ActiveRecord::TestCase
def test_primary_key_issues_warning
model = Class.new(ActiveRecord::Base) do
def self.table_name
- "barcodes"
+ "uber_barcodes"
end
end
warning = capture(:stderr) do
@@ -346,9 +346,9 @@ class CompositePrimaryKeyTest < ActiveRecord::TestCase
assert_match(/WARNING: Active Record does not support composite primary key\./, warning)
end
- def test_dumping_composite_primary_key
- schema = dump_table_schema "barcodes"
- assert_match %r{create_table "barcodes", primary_key: \["region", "code"\]}, schema
+ def test_collectly_dump_composite_primary_key
+ schema = dump_table_schema "uber_barcodes"
+ assert_match %r{create_table "uber_barcodes", primary_key: \["region", "code"\]}, schema
end
def test_dumping_composite_primary_key_out_of_order
diff --git a/activerecord/test/cases/query_cache_test.rb b/activerecord/test/cases/query_cache_test.rb
index 494663eb04..17b5304cc4 100644
--- a/activerecord/test/cases/query_cache_test.rb
+++ b/activerecord/test/cases/query_cache_test.rb
@@ -130,7 +130,7 @@ class QueryCacheTest < ActiveRecord::TestCase
assert_cache :off, conn
end
ensure
- ActiveRecord::Base.clear_all_connections!
+ ActiveRecord::Base.connection_pool.disconnect!
end
end
end
diff --git a/activerecord/test/cases/reload_models_test.rb b/activerecord/test/cases/reload_models_test.rb
index 3f4c0c03e3..38a8d84107 100644
--- a/activerecord/test/cases/reload_models_test.rb
+++ b/activerecord/test/cases/reload_models_test.rb
@@ -3,6 +3,8 @@ require "models/owner"
require "models/pet"
class ReloadModelsTest < ActiveRecord::TestCase
+ include ActiveSupport::Testing::Isolation
+
fixtures :pets, :owners
def test_has_one_with_reload
@@ -19,4 +21,4 @@ class ReloadModelsTest < ActiveRecord::TestCase
pet.owner = Owner.find_by_name("ashley")
assert_equal pet.owner, Owner.find_by_name("ashley")
end
-end
+end unless in_memory_db?
diff --git a/activerecord/test/cases/scoping/default_scoping_test.rb b/activerecord/test/cases/scoping/default_scoping_test.rb
index 89fb434b27..6f1010d701 100644
--- a/activerecord/test/cases/scoping/default_scoping_test.rb
+++ b/activerecord/test/cases/scoping/default_scoping_test.rb
@@ -486,6 +486,8 @@ class DefaultScopingWithThreadTest < ActiveRecord::TestCase
end
def test_default_scope_is_threadsafe
+ 2.times { ThreadsafeDeveloper.unscoped.create! }
+
threads = []
assert_not_equal 1, ThreadsafeDeveloper.unscoped.count
@@ -504,5 +506,7 @@ class DefaultScopingWithThreadTest < ActiveRecord::TestCase
ThreadsafeDeveloper.connection.close
end
threads.each(&:join)
+ ensure
+ ThreadsafeDeveloper.unscoped.destroy_all
end
end unless in_memory_db?
diff --git a/activesupport/test/current_attributes_test.rb b/activesupport/test/current_attributes_test.rb
index 67ef6ef619..a1f3b33444 100644
--- a/activesupport/test/current_attributes_test.rb
+++ b/activesupport/test/current_attributes_test.rb
@@ -28,7 +28,14 @@ class CurrentAttributesTest < ActiveSupport::TestCase
end
end
- setup { Current.reset }
+ setup do
+ @original_time_zone = Time.zone
+ Current.reset
+ end
+
+ teardown do
+ Time.zone = @original_time_zone
+ end
test "read and write attribute" do
Current.world = "world/1"
diff --git a/railties/test/application/test_test.rb b/railties/test/application/test_test.rb
index 32d2a6857c..2a1a6bcbfd 100644
--- a/railties/test/application/test_test.rb
+++ b/railties/test/application/test_test.rb
@@ -55,7 +55,7 @@ module ApplicationTests
end
RUBY
- assert_unsuccessful_run "unit/foo_test.rb", "Failed assertion"
+ assert_unsuccessful_run "unit/foo_test.rb", "Failure:\nFooTest#test_truth"
end
test "integration test" do