<commit_before># NOTE: based on connection pool test (from AR's test suite)
module ActiveRecord
  module ConnectionAdapters
    module ConnectionPoolTestMethods

      attr_reader :pool

      def setup
        ActiveRecord::Base.establish_connection(config)
      end

      def teardown
        pool.disconnect! if pool
      end

      def test_checkout_after_close
        connection = pool.connection
        assert connection.in_use?

        connection.close
        assert_false connection.in_use?

        assert_true pool.connection.in_use?
      end

      def test_released_connection_moves_between_threads
        thread_conn = nil

        Thread.new {
          pool.with_connection do |conn|
            thread_conn = conn
          end
        }.join

        assert thread_conn

        Thread.new {
          pool.with_connection do |conn|
            assert_equal thread_conn, conn
          end
        }.join<commit_msg>degrade truthy requirements for `in_use?` return value (due DefaultPool - AR 4.2)<commit_after># NOTE: based on connection pool test (from AR's test suite)
module ActiveRecord
  module ConnectionAdapters
    module ConnectionPoolTestMethods

      attr_reader :pool

      def setup
        ActiveRecord::Base.establish_connection(config)
      end

      def teardown
        pool.disconnect! if pool
      end

      def test_checkout_after_close
        connection = pool.connection
        assert connection.in_use?

        connection.close
        assert ! connection.in_use?

        assert pool.connection.in_use?
      end

      def test_released_connection_moves_between_threads
        thread_conn = nil

        Thread.new {
          pool.with_connection do |conn|
            thread_conn = conn
          end
        }.join

        assert thread_conn

        Thread.new {
          pool.with_connection do |conn|
            assert_equal thread_conn, conn
          end
        }.join
{'fraction_non_alphanumeric': 0.048378795676788475, 'fraction_numerical': 0.001029336078229542, 'mean_word_length': 2.0233281493001556, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '366250', 'n_tokens_mistral': 528, 'n_tokens_neox': 494, 'n_words': 137}