cucumber / cucumber-rails

Rails Generators for Cucumber with special support for Capybara and DatabaseCleaner
https://github.com/cucumber/cucumber-rails
MIT License
1.02k stars 327 forks source link

active_record hook prevents features that access multiple database from running correctly #152

Closed Confusion closed 13 years ago

Confusion commented 13 years ago

I have a feature that uses data from two separate database. This feature does not work when using cucumber-rails 1.0.2. The issue is that the first connection, to the regular Rails database, get stored as @@shared_connection in ActiveRecord::Base by the cucumber-rails active_record hook (lib/cucumber/rails/hooks/active_record.rb). After a connection to the second database is established, ActiveRecord::Base.connection still returns the @@shared_connection which is a connection to the wrong database.

A solution is to keep such a shared_connection per connection specification with which establish_connection has been invoked.

There are however other problems with this hook. For instance, it prevents you from writing features to test massively concurrent use of an application, by creating a bottleneck where the actual application has none.

The code was added in commit https://github.com/cucumber/cucumber-rails/commit/cbcfd88dc983340281db20915a80e3831c8f6950, but the commit message does not really explain why it was necessary.

jcf commented 13 years ago

I can verify that @winnipegtransit's change has fixed the issue. I guess it won't be merged until it has tests though.

aslakhellesoy commented 13 years ago

Forgot to close this