Skip to content

Commit 887683e

Browse files
authored
Rails 6.1: coerce tests when we produce more or less queries (#901)
* coerce test because we produce some read queries * coerce test because we open less transactions * change coerced test
1 parent 2b5a37a commit 887683e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/cases/coerced_tests.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ def test_errors_when_an_insert_query_prefixed_by_a_slash_star_comment_is_called_
6868
end
6969
end
7070
end
71+
72+
coerce_tests! :test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containing_read_command_is_called_while_preventing_writes
73+
def test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containing_read_command_is_called_while_preventing_writes_coerced
74+
Subscriber.send(:load_schema!)
75+
original_test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containing_read_command_is_called_while_preventing_writes
76+
end
7177
end
7278
end
7379

@@ -1693,3 +1699,31 @@ def test_has_many_through_has_and_belongs_to_many_with_has_many_source_reflectio
16931699
)
16941700
end
16951701
end
1702+
1703+
class BasePreventWritesTest < ActiveRecord::TestCase
1704+
# SQL Server does not have query for release_savepoint
1705+
coerce_tests! %r{an empty transaction does not raise if preventing writes}
1706+
test "an empty transaction does not raise if preventing writes coerced" do
1707+
ActiveRecord::Base.while_preventing_writes do
1708+
assert_queries(1, ignore_none: true) do
1709+
Bird.transaction do
1710+
ActiveRecord::Base.connection.materialize_transactions
1711+
end
1712+
end
1713+
end
1714+
end
1715+
end
1716+
1717+
class BasePreventWritesLegacyTest < ActiveRecord::TestCase
1718+
# SQL Server does not have query for release_savepoint
1719+
coerce_tests! %r{an empty transaction does not raise if preventing writes}
1720+
test "an empty transaction does not raise if preventing writes coerced" do
1721+
ActiveRecord::Base.connection_handler.while_preventing_writes do
1722+
assert_queries(1, ignore_none: true) do
1723+
Bird.transaction do
1724+
ActiveRecord::Base.connection.materialize_transactions
1725+
end
1726+
end
1727+
end
1728+
end
1729+
end

0 commit comments

Comments
 (0)