diff --git a/test/cases/coerced_tests.rb b/test/cases/coerced_tests.rb index fabd4fb98..afbfef5aa 100644 --- a/test/cases/coerced_tests.rb +++ b/test/cases/coerced_tests.rb @@ -68,6 +68,12 @@ def test_errors_when_an_insert_query_prefixed_by_a_slash_star_comment_is_called_ end end end + + coerce_tests! :test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containing_read_command_is_called_while_preventing_writes + def test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containing_read_command_is_called_while_preventing_writes_coerced + Subscriber.send(:load_schema!) + original_test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containing_read_command_is_called_while_preventing_writes + end end end @@ -1693,3 +1699,31 @@ def test_has_many_through_has_and_belongs_to_many_with_has_many_source_reflectio ) end end + +class BasePreventWritesTest < ActiveRecord::TestCase + # SQL Server does not have query for release_savepoint + coerce_tests! %r{an empty transaction does not raise if preventing writes} + test "an empty transaction does not raise if preventing writes coerced" do + ActiveRecord::Base.while_preventing_writes do + assert_queries(1, ignore_none: true) do + Bird.transaction do + ActiveRecord::Base.connection.materialize_transactions + end + end + end + end +end + +class BasePreventWritesLegacyTest < ActiveRecord::TestCase + # SQL Server does not have query for release_savepoint + coerce_tests! %r{an empty transaction does not raise if preventing writes} + test "an empty transaction does not raise if preventing writes coerced" do + ActiveRecord::Base.connection_handler.while_preventing_writes do + assert_queries(1, ignore_none: true) do + Bird.transaction do + ActiveRecord::Base.connection.materialize_transactions + end + end + end + end +end