influitive / apartment

Database multi-tenancy for Rack (and Rails) applications
2.68k stars 460 forks source link

warning: instance variable not initialized #655

Closed simonc closed 3 years ago

simonc commented 4 years ago

Steps to reproduce

Simply running RSpec with Apartment without setting connection_class or persistent_schemas explicitly.

Expected behavior

To have no warning show up in the specs output.

Actual behavior

A lot of warnings stating that

.../lib/apartment.rb:66: warning: instance variable @connection_class not initialized
.../lib/apartment.rb:62: warning: instance variable @persistent_schemas not initialized

System configuration

Personal note

That's not really a surprise as the connection_class and persistent_schemas methods are defined in a way that would indeed raise this warning if the variables are not already set.

If you're open to it I'd be happy to make a PR that assigns those variables to the default values that are returned.

❤️

Update: this PR is a duplicate of #538 that was closed. Update 2: My current workaround is to set the following in spec_helper.rb:

Apartment.configure do |config|
  config.connection_class = ActiveRecord::Base
  config.persistent_schemas = []
end
simonc commented 3 years ago

No activity or response for a year and from what I know the gem is dying anyway so I'll close this PR since there's a workaround 😉