diff options
author | Jonathan Viney <jonathan.viney@gmail.com> | 2008-07-02 16:01:26 +1200 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-07-15 21:25:12 +0200 |
commit | 4f72feb84c25b54f66c7192c788b7fd965f2d493 (patch) | |
tree | caa8cf9cb15c786dc627e438122da822986d8f6e /activerecord/test/cases | |
parent | 24a8ae4e08fcd15a8c3792990d1d0981d004d339 (diff) | |
download | rails-4f72feb84c25b54f66c7192c788b7fd965f2d493.tar.gz rails-4f72feb84c25b54f66c7192c788b7fd965f2d493.tar.bz2 rails-4f72feb84c25b54f66c7192c788b7fd965f2d493.zip |
Move the transaction counter to the connection object rather than maintaining it on the current Thread.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#533 state:resolved]
Diffstat (limited to 'activerecord/test/cases')
-rwxr-xr-x | activerecord/test/cases/fixtures_test.rb | 6 | ||||
-rw-r--r-- | activerecord/test/cases/multiple_db_test.rb | 25 |
2 files changed, 28 insertions, 3 deletions
diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb index 0ea24868f1..6ba7597f56 100755 --- a/activerecord/test/cases/fixtures_test.rb +++ b/activerecord/test/cases/fixtures_test.rb @@ -461,11 +461,11 @@ class FixturesBrokenRollbackTest < ActiveRecord::TestCase alias_method :teardown, :blank_teardown def test_no_rollback_in_teardown_unless_transaction_active - assert_equal 0, Thread.current['open_transactions'] + assert_equal 0, ActiveRecord::Base.connection.open_transactions assert_raise(RuntimeError) { ar_setup_fixtures } - assert_equal 0, Thread.current['open_transactions'] + assert_equal 0, ActiveRecord::Base.connection.open_transactions assert_nothing_raised { ar_teardown_fixtures } - assert_equal 0, Thread.current['open_transactions'] + assert_equal 0, ActiveRecord::Base.connection.open_transactions end private diff --git a/activerecord/test/cases/multiple_db_test.rb b/activerecord/test/cases/multiple_db_test.rb index eb3e43c8ac..7c3e0f2ca6 100644 --- a/activerecord/test/cases/multiple_db_test.rb +++ b/activerecord/test/cases/multiple_db_test.rb @@ -57,4 +57,29 @@ class MultipleDbTest < ActiveRecord::TestCase assert Course.connection end + + def test_transactions_across_databases + c1 = Course.find(1) + e1 = Entrant.find(1) + + begin + Course.transaction do + Entrant.transaction do + c1.name = "Typo" + e1.name = "Typo" + c1.save + e1.save + raise "No I messed up." + end + end + rescue + # Yup caught it + end + + assert_equal "Typo", c1.name + assert_equal "Typo", e1.name + + assert_equal "Ruby Development", Course.find(1).name + assert_equal "Ruby Developer", Entrant.find(1).name + end end |