Skip to content

Commit 4979857

Browse files
authored
Coerce test (#1283)
1 parent 55e17fc commit 4979857

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/cases/coerced_tests.rb

+12
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,18 @@ def test_payload_row_count_on_raw_sql_coerced
376376
end
377377

378378
class CalculationsTest < ActiveRecord::TestCase
379+
# SELECT columns must be in the GROUP clause.
380+
coerce_tests! :test_should_count_with_group_by_qualified_name_on_loaded
381+
def test_should_count_with_group_by_qualified_name_on_loaded_coerced
382+
accounts = Account.group("accounts.id").select("accounts.id")
383+
expected = { 1 => 1, 2 => 1, 3 => 1, 4 => 1, 5 => 1, 6 => 1 }
384+
assert_not_predicate accounts, :loaded?
385+
assert_equal expected, accounts.count
386+
accounts.load
387+
assert_predicate accounts, :loaded?
388+
assert_equal expected, accounts.count(:id)
389+
end
390+
379391
# Fix randomly failing test. The loading of the model's schema was affecting the test.
380392
coerce_tests! :test_offset_is_kept
381393
def test_offset_is_kept_coerced

0 commit comments

Comments
 (0)