Skip to content

Commit 82ce211

Browse files
committed
Transaction test with coerced to folder.
1 parent 483210e commit 82ce211

File tree

2 files changed

+33
-35
lines changed

2 files changed

+33
-35
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require 'cases/helper_sqlserver'
2+
3+
class TransactionTest < ActiveRecord::TestCase
4+
include ARTest::SQLServer::CoercedTest
5+
6+
COERCED_TESTS = [:test_releasing_named_savepoints]
7+
8+
def test_coerced_releasing_named_savepoints
9+
Topic.transaction do
10+
Topic.connection.create_savepoint("another")
11+
Topic.connection.release_savepoint("another")
12+
13+
# The origin rails test tries to re-release the savepoint, but
14+
# since sqlserver doesn't have the concept of releasing, it doesn't
15+
# fail, so we just omit that part here
16+
end
17+
end
18+
end

test/cases/transaction_test_sqlserver.rb

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,31 @@ class TransactionTestSQLServer < ActiveRecord::TestCase
66

77
self.use_transactional_fixtures = false
88

9-
setup :delete_ships
9+
before { delete_ships }
1010

11-
context 'Testing transaction basics' do
11+
it 'allow ActiveRecord::Rollback to work in 1 transaction block' do
12+
Ship.transaction do
13+
Ship.create! name: 'Black Pearl'
14+
raise ActiveRecord::Rollback
15+
end
16+
assert_no_ships
17+
end
1218

13-
should 'allow ActiveRecord::Rollback to work in 1 transaction block' do
19+
it 'allow nested transactions to totally rollback' do
20+
begin
1421
Ship.transaction do
1522
Ship.create! name: 'Black Pearl'
16-
raise ActiveRecord::Rollback
17-
end
18-
assert_no_ships
19-
end
20-
21-
should 'allow nested transactions to totally rollback' do
22-
begin
2323
Ship.transaction do
24-
Ship.create! name: 'Black Pearl'
25-
Ship.transaction do
26-
Ship.create! name: 'Flying Dutchman'
27-
raise 'HELL'
28-
end
24+
Ship.create! name: 'Flying Dutchman'
25+
raise 'HELL'
2926
end
30-
rescue Exception => e
31-
assert_no_ships
3227
end
28+
rescue Exception => e
29+
assert_no_ships
3330
end
34-
3531
end
3632

33+
3734
protected
3835

3936
def delete_ships
@@ -45,20 +42,3 @@ def assert_no_ships
4542
end
4643

4744
end
48-
49-
class TransactionTest < ActiveRecord::TestCase
50-
include ARTest::SQLServer::CoercedTest
51-
52-
COERCED_TESTS = [:test_releasing_named_savepoints]
53-
54-
def test_coerced_releasing_named_savepoints
55-
Topic.transaction do
56-
Topic.connection.create_savepoint("another")
57-
Topic.connection.release_savepoint("another")
58-
59-
# The origin rails test tries to re-release the savepoint, but
60-
# since sqlserver doesn't have the concept of releasing, it doesn't
61-
# fail, so we just omit that part here
62-
end
63-
end
64-
end

0 commit comments

Comments
 (0)