From 4e90fe0afdbd356159f59d3d65b4ce289602a342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Sun, 25 Sep 2011 10:56:00 +0100 Subject: [PATCH] Add back descendants iteration. Update History. --- History.md | 15 ++++++++++----- lib/cucumber/rails/hooks/active_record.rb | 16 +++++++++++----- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/History.md b/History.md index 2dea516a..4067e970 100755 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +## In Git + +### Bugfixes +* Fix deprecation warnings ([#169](https://github.com/cucumber/cucumber-rails/issues/169), [#170](https://github.com/cucumber/cucumber-rails/pull/170) Micah Geisel) + ## [v1.0.5](https://github.com/cucumber/cucumber-rails/compare/v1.0.4...v1.0.5) ### Bugfixes @@ -12,11 +17,11 @@ ### Bugfixes * sqlite3-ruby is now sqlite3 ([#158](https://github.com/cucumber/cucumber-rails/pull/158) Trung Le) -* Broken link in the USAGE file of the features generator ((#156)[https://github.com/cucumber/cucumber-rails/pull/156] Pablo Alonso García) -* Rails destroy cucumber:feature deletes the steps folder, even though it's not empty. ((#154)[https://github.com/cucumber/cucumber-rails/pull/154], (#111)[https://github.com/cucumber/cucumber-rails/issues/111] mblake) -* Adjust select_date, select_time xpaths so they work when scoped in the document ((#151)[https://github.com/cucumber/cucumber-rails/pull/151] Thomas Walpole) -* Extend javascript emulation to handle rails CSRF protection ((#164)[https://github.com/cucumber/cucumber-rails/pull/164] Jonathon M. Abbott) -* Add steps for finding fields with errors ((#162)[https://github.com/cucumber/cucumber-rails/pull/162] Mike Burns) +* Broken link in the USAGE file of the features generator ([#156](https://github.com/cucumber/cucumber-rails/pull/156) Pablo Alonso García) +* Rails destroy cucumber:feature deletes the steps folder, even though it's not empty. ([#154](https://github.com/cucumber/cucumber-rails/pull/154]), [#111](https://github.com/cucumber/cucumber-rails/issues/111) mblake) +* Adjust select_date, select_time xpaths so they work when scoped in the document ([#151](https://github.com/cucumber/cucumber-rails/pull/151) Thomas Walpole) +* Extend javascript emulation to handle rails CSRF protection ([#164](https://github.com/cucumber/cucumber-rails/pull/164) Jonathon M. Abbott) +* Add steps for finding fields with errors ([#162](https://github.com/cucumber/cucumber-rails/pull/162) Mike Burns) ## [v1.0.2](https://github.com/cucumber/cucumber-rails/compare/v1.0.1...v1.0.2) diff --git a/lib/cucumber/rails/hooks/active_record.rb b/lib/cucumber/rails/hooks/active_record.rb index c61badee..f06b5176 100644 --- a/lib/cucumber/rails/hooks/active_record.rb +++ b/lib/cucumber/rails/hooks/active_record.rb @@ -8,14 +8,20 @@ def self.connection end Before('@javascript') do - # Forces all threads to share a connection on a per-model basis, - # as connections may vary per model as per establish_connection. This works - # on Capybara because it starts the web server in a thread. - ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection - end + # Forces all threads to share a connection on a per-model basis, + # as connections may vary per model as per establish_connection. This works + # on Capybara because it starts the web server in a thread. + ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection + ActiveRecord::Base.descendants.each do |model| + model.shared_connection = model.connection + end + end Before('~@javascript') do # Do not use a shared connection unless we're in a @javascript scenario ActiveRecord::Base.shared_connection = nil + ActiveRecord::Base.descendants.each do |model| + model.shared_connection = nil + end end end \ No newline at end of file