method

setup_transactional_fixtures

rails latest stable - Class: ActiveRecord::TestFixtures

Method not available on this version

This method is only available on newer versions. The first available version (v7.2.3) is shown here.

setup_transactional_fixtures()
private

No documentation available.

# File activerecord/lib/active_record/test_fixtures.rb, line 161
      def setup_transactional_fixtures
        setup_shared_connection_pool

        # Begin transactions for connections already established
        @fixture_connection_pools = ActiveRecord::Base.connection_handler.connection_pool_list(:writing)
        @fixture_connection_pools.each do |pool|
          pool.pin_connection!(lock_threads)
          pool.lease_connection
        end

        # When connections are established in the future, begin a transaction too
        @connection_subscriber = ActiveSupport::Notifications.subscribe("!connection.active_record") do |_, _, _, _, payload|
          connection_name = payload[:connection_name] if payload.key?(:connection_name)
          shard = payload[:shard] if payload.key?(:shard)

          if connection_name
            pool = ActiveRecord::Base.connection_handler.retrieve_connection_pool(connection_name, shard: shard)
            if pool
              setup_shared_connection_pool

              unless @fixture_connection_pools.include?(pool)
                pool.pin_connection!(lock_threads)
                pool.lease_connection
                @fixture_connection_pools << pool
              end
            end
          end
        end
      end