aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2013-09-30 10:58:25 +0200
committerYves Senn <yves.senn@gmail.com>2013-09-30 15:29:40 +0200
commit032998ad7460c59916b8268467251d78c6cd18b7 (patch)
tree186f986600561473ffcd6c287f376378a5f20a86 /activerecord/test/cases
parent47a19ebe9bf2a2eaf7f56ad382b9b4fa1954a349 (diff)
downloadrails-032998ad7460c59916b8268467251d78c6cd18b7.tar.gz
rails-032998ad7460c59916b8268467251d78c6cd18b7.tar.bz2
rails-032998ad7460c59916b8268467251d78c6cd18b7.zip
change the savepoint interface to allow passing the name.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/transactions_test.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb
index a5cb22aaf6..17206ffe99 100644
--- a/activerecord/test/cases/transactions_test.rb
+++ b/activerecord/test/cases/transactions_test.rb
@@ -375,6 +375,36 @@ class TransactionTest < ActiveRecord::TestCase
assert_equal "Three", @three
end if Topic.connection.supports_savepoints?
+ def test_using_named_savepoints
+ Topic.transaction do
+ @first.approved = true
+ @first.save!
+ Topic.connection.create_savepoint("first")
+
+ @first.approved = false
+ @first.save!
+ Topic.connection.rollback_to_savepoint("first")
+ assert @first.reload.approved?
+
+ @first.approved = false
+ @first.save!
+ Topic.connection.release_savepoint("first")
+ assert_not @first.reload.approved?
+ end
+ end if Topic.connection.supports_savepoints?
+
+ def test_releasing_named_savepoints
+ Topic.transaction do
+ Topic.connection.create_savepoint("another")
+ Topic.connection.release_savepoint("another")
+
+ # The savepoint is now gone and we can't remove it again.
+ assert_raises(ActiveRecord::StatementInvalid) do
+ Topic.connection.release_savepoint("another")
+ end
+ end
+ end
+
def test_rollback_when_commit_raises
Topic.connection.expects(:begin_db_transaction)
Topic.connection.expects(:commit_db_transaction).raises('OH NOES')