• J
    Create connection.active_record notification and use that to ensure that lazy- · 31a8588a
    Jeremy Wadsack 提交于
    loaded model classes have their connections wrapped in transactions.
    
    See #17776
    
    In Rails 4 config.eager_load was changed to false in the test environment. This
    means that model classes that connect to alternate databases with
    establish_connection are not loaded at start up. If use_transactional_fixtures
    is enabled, transactions are wrapped around the connections that have been
    established only at the start of the test suite. So model classes loaded later
    don't have transactions causing data created in the alternate database not to
    be removed.
    
    This change resolves that by creating a new connection.active_record
    notification that gets fired whenever a connection is established. I then added
    a subscriber after we set up transactions in the test environment to listen for
    additional connections and wrap those in transactions as well.
    31a8588a
connection_pool_test.rb 17.5 KB