Skip to content

Commit

Permalink
Coerce test (#1283)
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanharan authored Jan 1, 2025
1 parent 55e17fc commit 4979857
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/cases/coerced_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,18 @@ def test_payload_row_count_on_raw_sql_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

0 comments on commit 4979857

Please sign in to comment.