Skip to content

Commit 2c9aad1

Browse files
authored
Coerce test (#1274)
1 parent 6e75574 commit 2c9aad1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/cases/coerced_tests.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,22 @@ def test_payload_affected_rows_coerced
383383
end
384384

385385
class CalculationsTest < ActiveRecord::TestCase
386+
# SELECT columns must be in the GROUP clause.
387+
coerce_tests! :test_should_count_with_group_by_qualified_name_on_loaded
388+
def test_should_count_with_group_by_qualified_name_on_loaded_coerced
389+
accounts = Account.group("accounts.id").select("accounts.id")
390+
391+
expected = { 1 => 1, 2 => 1, 3 => 1, 4 => 1, 5 => 1, 6 => 1 }
392+
393+
assert_not_predicate accounts, :loaded?
394+
assert_equal expected, accounts.count
395+
396+
accounts.load
397+
398+
assert_predicate accounts, :loaded?
399+
assert_equal expected, accounts.count(:id)
400+
end
401+
386402
# Fix randomly failing test. The loading of the model's schema was affecting the test.
387403
coerce_tests! :test_offset_is_kept
388404
def test_offset_is_kept_coerced

0 commit comments

Comments
 (0)