diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-10-09 07:48:27 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-10-09 07:48:27 +0000 |
commit | 2c3ca4c4e6d62eb00d46bcf767d04917428f27a7 (patch) | |
tree | a9013d126a9b1990691052d9e530a84f45d0768f /activerecord/lib/active_record | |
parent | 419226fe11e649afa8a1cd50a62dc4d5058d5860 (diff) | |
download | rails-2c3ca4c4e6d62eb00d46bcf767d04917428f27a7.tar.gz rails-2c3ca4c4e6d62eb00d46bcf767d04917428f27a7.tar.bz2 rails-2c3ca4c4e6d62eb00d46bcf767d04917428f27a7.zip |
Don't rollback in teardown unless a transaction was started. Don't start a transaction in create_fixtures if a transaction is started. Closes #6282.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5270 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/fixtures.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index e5d258288d..6882a44b71 100755 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -252,7 +252,7 @@ class Fixtures < YAML::Omap end all_loaded_fixtures.merge! fixtures_map - connection.transaction do + connection.transaction(Thread.current['open_transactions'] == 0) do fixtures.reverse.each { |fixture| fixture.delete_existing_fixtures } fixtures.each { |fixture| fixture.insert_fixtures } @@ -542,10 +542,10 @@ module Test #:nodoc: def teardown_with_fixtures return unless defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank? - # Rollback changes. - if use_transactional_fixtures? + # Rollback changes if a transaction is active. + if use_transactional_fixtures? && !Thread.current['open_transactions'].zero? ActiveRecord::Base.connection.rollback_db_transaction - ActiveRecord::Base.send :decrement_open_transactions + Thread.current['open_transactions'] = 0 end ActiveRecord::Base.verify_active_connections! end |