@@ -56,7 +56,7 @@ def test_partial_index_coerced
56
56
57
57
t = Topic . create! ( title : "abc" )
58
58
t . author_name = "John"
59
- assert_queries ( 1 ) do
59
+ assert_queries_count ( 1 ) do
60
60
t . valid?
61
61
end
62
62
end
@@ -234,7 +234,7 @@ def test_update_date_time_attributes_with_default_timezone_local
234
234
coerce_tests! %r{an empty transaction does not raise if preventing writes}
235
235
test "an empty transaction does not raise if preventing writes coerced" do
236
236
ActiveRecord ::Base . while_preventing_writes do
237
- assert_queries ( 1 , ignore_none : true ) do
237
+ assert_queries_count ( 1 , ignore_none : true ) do
238
238
Bird . transaction do
239
239
ActiveRecord ::Base . lease_connection . materialize_transactions
240
240
end
@@ -490,8 +490,8 @@ def test_limit_with_offset_is_kept_coerced
490
490
coerce_tests! :test_distinct_count_all_with_custom_select_and_order
491
491
def test_distinct_count_all_with_custom_select_and_order_coerced
492
492
accounts = Account . distinct . select ( "credit_limit % 10 AS the_limit" ) . order ( Arel . sql ( "credit_limit % 10" ) )
493
- assert_queries ( 1 ) { assert_equal 3 , accounts . count ( :all ) }
494
- assert_queries ( 1 ) { assert_equal 3 , accounts . load . size }
493
+ assert_queries_count ( 1 ) { assert_equal 3 , accounts . count ( :all ) }
494
+ assert_queries_count ( 1 ) { assert_equal 3 , accounts . load . size }
495
495
end
496
496
497
497
# Leave it up to users to format selects/functions so HAVING works correctly.
@@ -1018,7 +1018,7 @@ def test_implicit_order_column_is_configurable_coerced
1018
1018
assert_equal topics ( :fifth ) , Topic . first
1019
1019
assert_equal topics ( :third ) , Topic . last
1020
1020
1021
- c = Topic . connection
1021
+ c = Topic . lease_connection
1022
1022
assert_sql ( /ORDER BY #{ Regexp . escape ( c . quote_table_name ( "topics.title" ) ) } DESC, #{ Regexp . escape ( c . quote_table_name ( "topics.id" ) ) } DESC OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY.*@0 = 1/i ) {
1023
1023
Topic . last
1024
1024
}
@@ -1032,7 +1032,7 @@ def test_implicit_order_set_to_primary_key_coerced
1032
1032
old_implicit_order_column = Topic . implicit_order_column
1033
1033
Topic . implicit_order_column = "id"
1034
1034
1035
- c = Topic . connection
1035
+ c = Topic . lease_connection
1036
1036
assert_sql ( /ORDER BY #{ Regexp . escape ( c . quote_table_name ( "topics.id" ) ) } DESC OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY.*@0 = 1/i ) {
1037
1037
Topic . last
1038
1038
}
@@ -1046,7 +1046,7 @@ def test_implicit_order_for_model_without_primary_key_coerced
1046
1046
old_implicit_order_column = NonPrimaryKey . implicit_order_column
1047
1047
NonPrimaryKey . implicit_order_column = "created_at"
1048
1048
1049
- c = NonPrimaryKey . connection
1049
+ c = NonPrimaryKey . lease_connection
1050
1050
1051
1051
assert_sql ( /ORDER BY #{ Regexp . escape ( c . quote_table_name ( "non_primary_keys.created_at" ) ) } DESC OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY.*@0 = 1/i ) {
1052
1052
NonPrimaryKey . last
@@ -1067,7 +1067,7 @@ def test_member_on_unloaded_relation_with_composite_primary_key_coerced
1067
1067
# Check for `FETCH NEXT x ROWS` rather then `LIMIT`.
1068
1068
coerce_tests! :test_implicit_order_column_prepends_query_constraints
1069
1069
def test_implicit_order_column_prepends_query_constraints_coerced
1070
- c = ClothingItem . connection
1070
+ c = ClothingItem . lease_connection
1071
1071
ClothingItem . implicit_order_column = "description"
1072
1072
quoted_type = Regexp . escape ( c . quote_table_name ( "clothing_items.clothing_type" ) )
1073
1073
quoted_color = Regexp . escape ( c . quote_table_name ( "clothing_items.color" ) )
@@ -1083,7 +1083,7 @@ def test_implicit_order_column_prepends_query_constraints_coerced
1083
1083
# Check for `FETCH NEXT x ROWS` rather then `LIMIT`.
1084
1084
coerce_tests! %r{#last for a model with composite query constraints}
1085
1085
test "#last for a model with composite query constraints coerced" do
1086
- c = ClothingItem . connection
1086
+ c = ClothingItem . lease_connection
1087
1087
quoted_type = Regexp . escape ( c . quote_table_name ( "clothing_items.clothing_type" ) )
1088
1088
quoted_color = Regexp . escape ( c . quote_table_name ( "clothing_items.color" ) )
1089
1089
@@ -1095,7 +1095,7 @@ def test_implicit_order_column_prepends_query_constraints_coerced
1095
1095
# Check for `FETCH NEXT x ROWS` rather then `LIMIT`.
1096
1096
coerce_tests! %r{#first for a model with composite query constraints}
1097
1097
test "#first for a model with composite query constraints coerced" do
1098
- c = ClothingItem . connection
1098
+ c = ClothingItem . lease_connection
1099
1099
quoted_type = Regexp . escape ( c . quote_table_name ( "clothing_items.clothing_type" ) )
1100
1100
quoted_color = Regexp . escape ( c . quote_table_name ( "clothing_items.color" ) )
1101
1101
@@ -1107,7 +1107,7 @@ def test_implicit_order_column_prepends_query_constraints_coerced
1107
1107
# Check for `FETCH NEXT x ROWS` rather then `LIMIT`.
1108
1108
coerce_tests! :test_implicit_order_column_reorders_query_constraints
1109
1109
def test_implicit_order_column_reorders_query_constraints_coerced
1110
- c = ClothingItem . connection
1110
+ c = ClothingItem . lease_connection
1111
1111
ClothingItem . implicit_order_column = "color"
1112
1112
quoted_type = Regexp . escape ( c . quote_table_name ( "clothing_items.clothing_type" ) )
1113
1113
quoted_color = Regexp . escape ( c . quote_table_name ( "clothing_items.color" ) )
@@ -1131,7 +1131,7 @@ def test_include_on_unloaded_relation_with_composite_primary_key_coerced
1131
1131
# Check for `FETCH NEXT x ROWS` rather then `LIMIT`.
1132
1132
coerce_tests! :test_nth_to_last_with_order_uses_limit
1133
1133
def test_nth_to_last_with_order_uses_limit_coerced
1134
- c = Topic . connection
1134
+ c = Topic . lease_connection
1135
1135
assert_sql ( /ORDER BY #{ Regexp . escape ( c . quote_table_name ( "topics.id" ) ) } DESC OFFSET @(\d ) ROWS FETCH NEXT @(\d ) ROWS ONLY.*@\1 = 1.*@\2 = 1/i ) do
1136
1136
Topic . second_to_last
1137
1137
end
@@ -1324,7 +1324,7 @@ def test_create_without_primary_key_no_extra_query_coerced
1324
1324
self . table_name = "dashboards"
1325
1325
end
1326
1326
klass . create! # warmup schema cache
1327
- assert_queries ( 2 , ignore_none : true ) { klass . create! }
1327
+ assert_queries_count ( 2 , ignore_none : true ) { klass . create! }
1328
1328
end
1329
1329
end
1330
1330
@@ -1354,7 +1354,7 @@ def test_query_cached_even_when_types_are_reset_coerced
1354
1354
Task . initialize_find_by_cache
1355
1355
Task . define_attribute_methods
1356
1356
1357
- assert_queries ( 1 , ignore_none : true ) do
1357
+ assert_queries_count ( 1 , ignore_none : true ) do
1358
1358
Task . find ( 1 )
1359
1359
end
1360
1360
@@ -1454,11 +1454,11 @@ def test_relations_dont_load_all_records_in_pretty_print_coerced
1454
1454
def test_empty_complex_chained_relations_coerced
1455
1455
posts = Post . select ( "comments_count" ) . where ( "id is not null" ) . group ( "author_id" , "id" ) . where ( "legacy_comments_count > 0" )
1456
1456
1457
- assert_queries ( 1 ) { assert_equal false , posts . empty? }
1457
+ assert_queries_count ( 1 ) { assert_equal false , posts . empty? }
1458
1458
assert_not_predicate posts , :loaded?
1459
1459
1460
1460
no_posts = posts . where ( title : "" )
1461
- assert_queries ( 1 ) { assert_equal true , no_posts . empty? }
1461
+ assert_queries_count ( 1 ) { assert_equal true , no_posts . empty? }
1462
1462
assert_not_predicate no_posts , :loaded?
1463
1463
end
1464
1464
@@ -2338,7 +2338,7 @@ def test_preloads_has_many_on_model_with_a_composite_primary_key_through_id_attr
2338
2338
assert_equal 2 , sql . size
2339
2339
preload_sql = sql . last
2340
2340
2341
- c = Cpk ::OrderAgreement . connection
2341
+ c = Cpk ::OrderAgreement . lease_connection
2342
2342
order_id_column = Regexp . escape ( c . quote_table_name ( "cpk_order_agreements.order_id" ) )
2343
2343
order_id_constraint = /#{ order_id_column } = @0.*@0 = \d +$/
2344
2344
expectation = /SELECT.*WHERE.* #{ order_id_constraint } /
@@ -2362,7 +2362,7 @@ def test_preloads_belongs_to_a_composite_primary_key_model_through_id_attribute_
2362
2362
assert_equal 2 , sql . size
2363
2363
preload_sql = sql . last
2364
2364
2365
- c = Cpk ::Order . connection
2365
+ c = Cpk ::Order . lease_connection
2366
2366
order_id = Regexp . escape ( c . quote_table_name ( "cpk_orders.id" ) )
2367
2367
order_constraint = /#{ order_id } = @0.*@0 = \d +$/
2368
2368
expectation = /SELECT.*WHERE.* #{ order_constraint } /
@@ -2377,7 +2377,7 @@ class BasePreventWritesTest < ActiveRecord::TestCase
2377
2377
coerce_tests! %r{an empty transaction does not raise if preventing writes}
2378
2378
test "an empty transaction does not raise if preventing writes coerced" do
2379
2379
ActiveRecord ::Base . while_preventing_writes do
2380
- assert_queries ( 1 , ignore_none : true ) do
2380
+ assert_queries_count ( 1 , ignore_none : true ) do
2381
2381
Bird . transaction do
2382
2382
ActiveRecord ::Base . lease_connection . materialize_transactions
2383
2383
end
0 commit comments