Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename assert_queries test #1158

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions test/cases/coerced_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_partial_index_coerced

t = Topic.create!(title: "abc")
t.author_name = "John"
assert_queries(1) do
assert_queries_count(1) do
t.valid?
end
end
Expand Down Expand Up @@ -234,7 +234,7 @@ def test_update_date_time_attributes_with_default_timezone_local
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
assert_queries_count(1, ignore_none: true) do
Bird.transaction do
ActiveRecord::Base.lease_connection.materialize_transactions
end
Expand Down Expand Up @@ -490,8 +490,8 @@ def test_limit_with_offset_is_kept_coerced
coerce_tests! :test_distinct_count_all_with_custom_select_and_order
def test_distinct_count_all_with_custom_select_and_order_coerced
accounts = Account.distinct.select("credit_limit % 10 AS the_limit").order(Arel.sql("credit_limit % 10"))
assert_queries(1) { assert_equal 3, accounts.count(:all) }
assert_queries(1) { assert_equal 3, accounts.load.size }
assert_queries_count(1) { assert_equal 3, accounts.count(:all) }
assert_queries_count(1) { assert_equal 3, accounts.load.size }
end

# Leave it up to users to format selects/functions so HAVING works correctly.
Expand Down Expand Up @@ -1324,7 +1324,7 @@ def test_create_without_primary_key_no_extra_query_coerced
self.table_name = "dashboards"
end
klass.create! # warmup schema cache
assert_queries(2, ignore_none: true) { klass.create! }
assert_queries_count(2, ignore_none: true) { klass.create! }
end
end

Expand Down Expand Up @@ -1354,7 +1354,7 @@ def test_query_cached_even_when_types_are_reset_coerced
Task.initialize_find_by_cache
Task.define_attribute_methods

assert_queries(1, ignore_none: true) do
assert_queries_count(1, ignore_none: true) do
Task.find(1)
end

Expand Down Expand Up @@ -1454,11 +1454,11 @@ def test_relations_dont_load_all_records_in_pretty_print_coerced
def test_empty_complex_chained_relations_coerced
posts = Post.select("comments_count").where("id is not null").group("author_id", "id").where("legacy_comments_count > 0")

assert_queries(1) { assert_equal false, posts.empty? }
assert_queries_count(1) { assert_equal false, posts.empty? }
assert_not_predicate posts, :loaded?

no_posts = posts.where(title: "")
assert_queries(1) { assert_equal true, no_posts.empty? }
assert_queries_count(1) { assert_equal true, no_posts.empty? }
assert_not_predicate no_posts, :loaded?
end

Expand Down Expand Up @@ -2377,7 +2377,7 @@ class BasePreventWritesTest < ActiveRecord::TestCase
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
assert_queries_count(1, ignore_none: true) do
Bird.transaction do
ActiveRecord::Base.lease_connection.materialize_transactions
end
Expand Down
2 changes: 1 addition & 1 deletion test/cases/eager_load_too_many_ids_test_sqlserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_batch_preloading_too_many_ids
# We Monkey patch Preloader to work with batches of 10_000 records.
# Expect: N Books queries + Citation query
expected_query_count = (Citation.count / in_clause_length.to_f).ceil + 1
assert_queries(expected_query_count) do
assert_queries_count(expected_query_count) do
Citation.preload(:reference_of).to_a.size
end
end
Expand Down
Loading