• E
    Fix connection pools not shared between writer -> replica during tests: · 13015b38
    Edouard CHIN 提交于
    - ### Problem
    
      Connection pools are not properly shared. A replica can't see the
      data in the open transaction on the writing connection.
      ```ruby
      Dog.create!(name: 'bilou')
    
      AnimalsBase.connected_to(role: :reading) do
        Dog.find_by(name: 'bilou') # No result
      end
      ```
    
      The reason of this bug is because when test starts, we iterate
      over `AR::Base.connection_handlers` which only contains the `writing`
      handler since models haven't been loaded (app isn't eagerloaded
      test env).
    
      ### Solution
    
      Share connection pools as soon as a connection is established
      by creating a subcriber.
    13015b38
fixtures_test.rb 44.8 KB