pat / combustion

Simple, elegant testing for Rails Engines
MIT License
708 stars 51 forks source link

"No connection pool with 'primary' found." #86

Closed jrochkind closed 6 years ago

jrochkind commented 6 years ago

In the process of trying to change my existing gem over to use combution. My tests run correctly when I do Combustion.initialize! :active_record. But when I try to switch over to just Combustion.initialize!, so I can start adding integration tests that use other parts of rails, every access to the db results in a ActiveRecord::ConnectionNotEstablished: No connection pool with 'primary' found.

Any ideas? I'm at a bit of a loss.

Example stack trace:

       ActiveRecord::ConnectionNotEstablished:
         No connection pool with 'primary' found.
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:1007:in `retrieve_connection'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/connection_handling.rb:118:in `retrieve_connection'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/connection_handling.rb:90:in `connection'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/model_schema.rb:466:in `load_schema!'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/attributes.rb:234:in `load_schema!'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/attribute_decorators.rb:51:in `load_schema!'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/model_schema.rb:459:in `block in load_schema'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/model_schema.rb:456:in `load_schema'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/model_schema.rb:346:in `attribute_types'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/attribute_methods.rb:230:in `has_attribute?'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/inheritance.rb:55:in `new'
       # ./spec/query_scopes_spec.rb:18:in `block (2 levels) in <top (required)>'
       # ./spec/query_scopes_spec.rb:22:in `block (3 levels) in <top (required)>'
jrochkind commented 6 years ago

Oh, duh. I need Combustion.initialize! :all, not just Combustion.initialize! with no args. Somehow I thought :all was the default.

Now my tests are running... I'm getting failures I wasn't getting with Combustion.initialize! :active_record, but that must be due to rails setting things up differently somehow.

pat commented 6 years ago

Once upon a time specifying no arguments for Combustion.initialize! meant load everything, but that was changed in 876512c700080a41058f7fa8b92a9391c5834d07 five years ago by @parndt. I think I'm mostly happy with the current behaviour - I like things to be a little more explicit.

I've been thinking of whether there any situation where having no arguments (and thus, loading no Rails components) would make sense… the only case would be where you want something that works with Rails, but doesn't make use of any of the active/action gems. Which is certainly valid! So, I'll keep things as they are for now.