Skip to content

Coerce test #1274

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

Merged
merged 1 commit into from
Dec 19, 2024
Merged
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
16 changes: 16 additions & 0 deletions test/cases/coerced_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,22 @@ def test_payload_affected_rows_coerced
end

class CalculationsTest < ActiveRecord::TestCase
# SELECT columns must be in the GROUP clause.
coerce_tests! :test_should_count_with_group_by_qualified_name_on_loaded
def test_should_count_with_group_by_qualified_name_on_loaded_coerced
accounts = Account.group("accounts.id").select("accounts.id")

expected = { 1 => 1, 2 => 1, 3 => 1, 4 => 1, 5 => 1, 6 => 1 }

assert_not_predicate accounts, :loaded?
assert_equal expected, accounts.count

accounts.load

assert_predicate accounts, :loaded?
assert_equal expected, accounts.count(:id)
end

# Fix randomly failing test. The loading of the model's schema was affecting the test.
coerce_tests! :test_offset_is_kept
def test_offset_is_kept_coerced
Expand Down