Skip to content

Commit 422b28b

Browse files
committed
coerce test because we open less transactions
1 parent 0d5b069 commit 422b28b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/cases/coerced_tests.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,3 +1674,31 @@ def marshal_fixture_path(file_name)
16741674
)
16751675
end
16761676
end
1677+
1678+
class BasePreventWritesTest < ActiveRecord::TestCase
1679+
# We open one transaction, not two. Same as original but checking one query
1680+
coerce_tests! %r{an empty transaction does not raise if preventing writes}
1681+
test "an empty transaction does not raise if preventing writes coerced" do
1682+
ActiveRecord::Base.while_preventing_writes do
1683+
assert_queries(1, ignore_none: true) do
1684+
Bird.transaction do
1685+
ActiveRecord::Base.connection.materialize_transactions
1686+
end
1687+
end
1688+
end
1689+
end
1690+
end
1691+
1692+
class BasePreventWritesLegacyTest < ActiveRecord::TestCase
1693+
# We open one transaction, not two. Same as original but checking one query
1694+
coerce_tests! %r{an empty transaction does not raise if preventing writes}
1695+
test "an empty transaction does not raise if preventing writes coerced" do
1696+
ActiveRecord::Base.connection_handler.while_preventing_writes do
1697+
assert_queries(1, ignore_none: true) do
1698+
Bird.transaction do
1699+
ActiveRecord::Base.connection.materialize_transactions
1700+
end
1701+
end
1702+
end
1703+
end
1704+
end

0 commit comments

Comments
 (0)