diff options
22 files changed, 47 insertions, 114 deletions
diff --git a/actioncable/test/test_helper.rb b/actioncable/test/test_helper.rb index 033f034b0c..b4408b3d6f 100644 --- a/actioncable/test/test_helper.rb +++ b/actioncable/test/test_helper.rb @@ -2,7 +2,6 @@ require "action_cable" require "active_support/testing/autorun" -require "active_support/testing/method_call_assertions" require "puma" require "rack/mock" @@ -20,8 +19,6 @@ ActionCable.server.config.cable = { "adapter" => "test" } ActionCable.server.config.logger = Logger.new(nil) class ActionCable::TestCase < ActiveSupport::TestCase - include ActiveSupport::Testing::MethodCallAssertions - def wait_for_async wait_for_executor Concurrent.global_io_executor end diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb index a2a603834c..0f3490a85f 100644 --- a/actionmailer/test/abstract_unit.rb +++ b/actionmailer/test/abstract_unit.rb @@ -16,7 +16,6 @@ module Rails end require "active_support/testing/autorun" -require "active_support/testing/method_call_assertions" require "action_mailer" require "action_mailer/test_case" @@ -35,19 +34,4 @@ ActionMailer::Base.view_paths = FIXTURE_LOAD_PATH ActionMailer::Base.delivery_job = ActionMailer::MailDeliveryJob -class ActiveSupport::TestCase - include ActiveSupport::Testing::MethodCallAssertions - - private - # Skips the current run on Rubinius using Minitest::Assertions#skip - def rubinius_skip(message = "") - skip message if RUBY_ENGINE == "rbx" - end - - # Skips the current run on JRuby using Minitest::Assertions#skip - def jruby_skip(message = "") - skip message if defined?(JRUBY_VERSION) - end -end - require_relative "../../tools/test_common" diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 1decfcee95..238ce32ce6 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -350,23 +350,6 @@ class CommentsController < ResourcesController; end class AccountsController < ResourcesController; end class ImagesController < ResourcesController; end -require "active_support/testing/method_call_assertions" - -class ActiveSupport::TestCase - include ActiveSupport::Testing::MethodCallAssertions - - private - # Skips the current run on Rubinius using Minitest::Assertions#skip - def rubinius_skip(message = "") - skip message if RUBY_ENGINE == "rbx" - end - - # Skips the current run on JRuby using Minitest::Assertions#skip - def jruby_skip(message = "") - skip message if defined?(JRUBY_VERSION) - end -end - class DrivenByRackTest < ActionDispatch::SystemTestCase driven_by :rack_test end diff --git a/actionview/test/abstract_unit.rb b/actionview/test/abstract_unit.rb index b652f2e6cb..debf553689 100644 --- a/actionview/test/abstract_unit.rb +++ b/actionview/test/abstract_unit.rb @@ -16,7 +16,6 @@ silence_warnings do end require "active_support/testing/autorun" -require "active_support/testing/method_call_assertions" require "action_controller" require "action_view" require "action_view/testing/resolvers" @@ -193,19 +192,6 @@ end class ActiveSupport::TestCase parallelize - - include ActiveSupport::Testing::MethodCallAssertions - - private - # Skips the current run on Rubinius using Minitest::Assertions#skip - def rubinius_skip(message = "") - skip message if RUBY_ENGINE == "rbx" - end - - # Skips the current run on JRuby using Minitest::Assertions#skip - def jruby_skip(message = "") - skip message if defined?(JRUBY_VERSION) - end end require_relative "../../tools/test_common" diff --git a/activemodel/test/cases/helper.rb b/activemodel/test/cases/helper.rb index c6335ac9e3..786b54983c 100644 --- a/activemodel/test/cases/helper.rb +++ b/activemodel/test/cases/helper.rb @@ -9,22 +9,6 @@ ActiveSupport::Deprecation.debug = true I18n.enforce_available_locales = false require "active_support/testing/autorun" -require "active_support/testing/method_call_assertions" require "active_support/core_ext/integer/time" -class ActiveModel::TestCase < ActiveSupport::TestCase - include ActiveSupport::Testing::MethodCallAssertions - - private - # Skips the current run on Rubinius using Minitest::Assertions#skip - def rubinius_skip(message = "") - skip message if RUBY_ENGINE == "rbx" - end - - # Skips the current run on JRuby using Minitest::Assertions#skip - def jruby_skip(message = "") - skip message if defined?(JRUBY_VERSION) - end -end - require_relative "../../../tools/test_common" diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 29e2e2cedc..2876bae302 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -1114,7 +1114,7 @@ module ActiveRecord else join end - end.compact_blank! + end.compact_blank!.uniq! while joins.first.is_a?(Arel::Nodes::Join) join_node = joins.shift @@ -1144,8 +1144,8 @@ module ActiveRecord def build_join_query(manager, buckets, join_type, aliases) association_joins = buckets[:association_join] stashed_joins = buckets[:stashed_join] - leading_joins = buckets[:leading_join].tap(&:uniq!) - join_nodes = buckets[:join_node].tap(&:uniq!) + leading_joins = buckets[:leading_join] + join_nodes = buckets[:join_node] join_sources = manager.join_sources join_sources.concat(leading_joins) unless leading_joins.empty? diff --git a/activerecord/test/cases/associations/inner_join_association_test.rb b/activerecord/test/cases/associations/inner_join_association_test.rb index b65af4b819..166a59ec7b 100644 --- a/activerecord/test/cases/associations/inner_join_association_test.rb +++ b/activerecord/test/cases/associations/inner_join_association_test.rb @@ -69,6 +69,16 @@ class InnerJoinAssociationTest < ActiveRecord::TestCase assert_equal [expected], Person.joins(string_join).joins(agents.create_join(agents, agents.create_on(constraint))) end + def test_deduplicate_joins + posts = Post.arel_table + constraint = posts[:author_id].eq(Author.arel_attribute(:id)) + + authors = Author.joins(posts.create_join(posts, posts.create_on(constraint))) + authors = authors.joins(:author_address).merge(authors.where("posts.type": "SpecialPost")) + + assert_equal [authors(:david)], authors + end + def test_construct_finder_sql_ignores_empty_joins_hash sql = Author.joins({}).to_sql assert_no_match(/JOIN/i, sql) diff --git a/activerecord/test/cases/test_case.rb b/activerecord/test/cases/test_case.rb index 1b8bad32a4..be74acf3d4 100644 --- a/activerecord/test/cases/test_case.rb +++ b/activerecord/test/cases/test_case.rb @@ -2,7 +2,6 @@ require "active_support" require "active_support/testing/autorun" -require "active_support/testing/method_call_assertions" require "active_support/testing/stream" require "active_record/fixtures" @@ -13,7 +12,6 @@ module ActiveRecord # # 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 diff --git a/activestorage/test/models/blob_test.rb b/activestorage/test/models/blob_test.rb index 9fd75a1b4a..57c6333401 100644 --- a/activestorage/test/models/blob_test.rb +++ b/activestorage/test/models/blob_test.rb @@ -2,11 +2,8 @@ require "test_helper" require "database/setup" -require "active_support/testing/method_call_assertions" class ActiveStorage::BlobTest < ActiveSupport::TestCase - include ActiveSupport::Testing::MethodCallAssertions - test "unattached scope" do [ create_blob(filename: "funky.jpg"), create_blob(filename: "town.jpg") ].tap do |blobs| User.create! name: "DHH", avatar: blobs.first diff --git a/activesupport/lib/active_support/core_ext/marshal.rb b/activesupport/lib/active_support/core_ext/marshal.rb index 0c72cd7b47..5ff0e34d82 100644 --- a/activesupport/lib/active_support/core_ext/marshal.rb +++ b/activesupport/lib/active_support/core_ext/marshal.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "active_support/core_ext/string/inflections" + module ActiveSupport module MarshalWithAutoloading # :nodoc: def load(source, proc = nil) diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index 94d1115ccf..33a17a7741 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "active_support/inflections" +require "active_support/core_ext/object/blank" module ActiveSupport # The Inflector transforms words from singular to plural, class names to table diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb index 7be4108ed7..c513c76315 100644 --- a/activesupport/lib/active_support/test_case.rb +++ b/activesupport/lib/active_support/test_case.rb @@ -5,6 +5,7 @@ require "minitest" require "active_support/testing/tagged_logging" require "active_support/testing/setup_and_teardown" require "active_support/testing/assertions" +require "active_support/testing/method_call_assertions" require "active_support/testing/deprecation" require "active_support/testing/declarative" require "active_support/testing/isolation" @@ -12,6 +13,7 @@ require "active_support/testing/constant_lookup" require "active_support/testing/time_helpers" require "active_support/testing/file_fixtures" require "active_support/testing/parallelization" +require "active_support/testing/alternative_runtime_skipper" require "concurrent/utility/processor_counter" module ActiveSupport @@ -137,10 +139,13 @@ module ActiveSupport include ActiveSupport::Testing::TaggedLogging prepend ActiveSupport::Testing::SetupAndTeardown include ActiveSupport::Testing::Assertions + include ActiveSupport::Testing::MethodCallAssertions include ActiveSupport::Testing::Deprecation include ActiveSupport::Testing::TimeHelpers include ActiveSupport::Testing::FileFixtures extend ActiveSupport::Testing::Declarative + include ActiveSupport::Testing::AlternativeRuntimeSkipper + # test/unit backwards compatibility methods alias :assert_raise :assert_raises diff --git a/activesupport/lib/active_support/testing/alternative_runtime_skipper.rb b/activesupport/lib/active_support/testing/alternative_runtime_skipper.rb new file mode 100644 index 0000000000..f9e6eaff2f --- /dev/null +++ b/activesupport/lib/active_support/testing/alternative_runtime_skipper.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module ActiveSupport + module Testing + module AlternativeRuntimeSkipper + private + # Skips the current run on Rubinius using Minitest::Assertions#skip + def rubinius_skip(message = "") + skip message if RUBY_ENGINE == "rbx" + end + + # Skips the current run on JRuby using Minitest::Assertions#skip + def jruby_skip(message = "") + skip message if defined?(JRUBY_VERSION) + end + end + end +end diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index 01e60abd99..a14748a6b3 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -10,7 +10,6 @@ silence_warnings do end require "active_support/testing/autorun" -require "active_support/testing/method_call_assertions" ENV["NO_RELOAD"] = "1" require "active_support" @@ -26,19 +25,4 @@ ActiveSupport.to_time_preserves_timezone = ENV["PRESERVE_TIMEZONES"] == "1" # Disable available locale checks to avoid warnings running the test suite. I18n.enforce_available_locales = false -class ActiveSupport::TestCase - include ActiveSupport::Testing::MethodCallAssertions - - private - # Skips the current run on Rubinius using Minitest::Assertions#skip - def rubinius_skip(message = "") - skip message if RUBY_ENGINE == "rbx" - end - - # Skips the current run on JRuby using Minitest::Assertions#skip - def jruby_skip(message = "") - skip message if defined?(JRUBY_VERSION) - end -end - require_relative "../../tools/test_common" diff --git a/activesupport/test/core_ext/object/acts_like_test.rb b/activesupport/test/core_ext/object/acts_like_test.rb index 31241caf0a..8aa9eb036a 100644 --- a/activesupport/test/core_ext/object/acts_like_test.rb +++ b/activesupport/test/core_ext/object/acts_like_test.rb @@ -1,7 +1,10 @@ # frozen_string_literal: true require "abstract_unit" -require "active_support/core_ext/object" +require "active_support/core_ext/date/acts_like" +require "active_support/core_ext/time/acts_like" +require "active_support/core_ext/date_time/acts_like" +require "active_support/core_ext/object/acts_like" class ObjectTests < ActiveSupport::TestCase class DuckTime diff --git a/activesupport/test/core_ext/object/deep_dup_test.rb b/activesupport/test/core_ext/object/deep_dup_test.rb index 1fb26ebac7..8e5e28c513 100644 --- a/activesupport/test/core_ext/object/deep_dup_test.rb +++ b/activesupport/test/core_ext/object/deep_dup_test.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require "abstract_unit" -require "active_support/core_ext/object" +require "active_support/core_ext/object/deep_dup" class DeepDupTest < ActiveSupport::TestCase def test_array_deep_dup diff --git a/activesupport/test/core_ext/object/instance_variables_test.rb b/activesupport/test/core_ext/object/instance_variables_test.rb index 9052d209a3..dd710e9349 100644 --- a/activesupport/test/core_ext/object/instance_variables_test.rb +++ b/activesupport/test/core_ext/object/instance_variables_test.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require "abstract_unit" -require "active_support/core_ext/object" +require "active_support/core_ext/object/instance_variables" class ObjectInstanceVariableTest < ActiveSupport::TestCase def setup diff --git a/activesupport/test/core_ext/object/json_gem_encoding_test.rb b/activesupport/test/core_ext/object/json_gem_encoding_test.rb index 4cdb6ed09f..eef02f7458 100644 --- a/activesupport/test/core_ext/object/json_gem_encoding_test.rb +++ b/activesupport/test/core_ext/object/json_gem_encoding_test.rb @@ -22,7 +22,7 @@ class JsonGemEncodingTest < ActiveSupport::TestCase JSONTest::EncodingTestCases.constants.each_with_index do |name| JSONTest::EncodingTestCases.const_get(name).each_with_index do |(subject, _), i| - test("#{name[0..-6].underscore} #{i}") do + test("#{name[0..-6]} #{i}") do assert_same_with_or_without_active_support(subject) end end diff --git a/activesupport/test/core_ext/object/try_test.rb b/activesupport/test/core_ext/object/try_test.rb index a838334034..d501b5edce 100644 --- a/activesupport/test/core_ext/object/try_test.rb +++ b/activesupport/test/core_ext/object/try_test.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require "abstract_unit" -require "active_support/core_ext/object" +require "active_support/core_ext/object/try" class ObjectTryTest < ActiveSupport::TestCase def setup diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb index 9600194ed6..93d09aad55 100644 --- a/railties/test/abstract_unit.rb +++ b/railties/test/abstract_unit.rb @@ -18,19 +18,4 @@ module TestApp end end -class ActiveSupport::TestCase - include ActiveSupport::Testing::Stream - - private - # Skips the current run on Rubinius using Minitest::Assertions#skip - def rubinius_skip(message = "") - skip message if RUBY_ENGINE == "rbx" - end - - # Skips the current run on JRuby using Minitest::Assertions#skip - def jruby_skip(message = "") - skip message if defined?(JRUBY_VERSION) - end -end - require_relative "../../tools/test_common" diff --git a/railties/test/generators/generators_test_helper.rb b/railties/test/generators/generators_test_helper.rb index 8b42cb83db..c68ba46a9a 100644 --- a/railties/test/generators/generators_test_helper.rb +++ b/railties/test/generators/generators_test_helper.rb @@ -3,7 +3,6 @@ require "abstract_unit" require "active_support/core_ext/module/remove_method" require "active_support/testing/stream" -require "active_support/testing/method_call_assertions" require "rails/generators" require "rails/generators/test_case" @@ -28,7 +27,6 @@ require "action_view" module GeneratorsTestHelper include ActiveSupport::Testing::Stream - include ActiveSupport::Testing::MethodCallAssertions GemfileEntry = Struct.new(:name, :version, :comment, :options, :commented_out) do def initialize(name, version, comment, options = {}, commented_out = false) diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 6077ba3ee7..40731d5f07 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -14,7 +14,6 @@ require "bundler/setup" unless defined?(Bundler) require "active_support" require "active_support/testing/autorun" require "active_support/testing/stream" -require "active_support/testing/method_call_assertions" require "active_support/test_case" require "minitest/retry" @@ -495,7 +494,6 @@ class ActiveSupport::TestCase include TestHelpers::Generation include TestHelpers::Reload include ActiveSupport::Testing::Stream - include ActiveSupport::Testing::MethodCallAssertions end # Create a scope and build a fixture rails app |