File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -392,6 +392,17 @@ def test_distinct_count_with_group_by_and_order_and_limit
392
392
assert_equal ( { 6 => 2 } , Account . group ( :firm_id ) . distinct . order ( "1 DESC" ) . limit ( 1 ) . count )
393
393
end
394
394
395
+ def test_count_for_a_composite_primary_key_model
396
+ book = cpk_books ( :cpk_great_author_first_book )
397
+ assert_equal ( 1 , Cpk ::Book . where ( author_id : book . author_id , number : book . number ) . count )
398
+ end
399
+
400
+ def test_group_by_count_for_a_composite_primary_key_model
401
+ book = cpk_books ( :cpk_great_author_first_book )
402
+ expected = { book . author_id => Cpk ::Book . where ( author_id : book . author_id ) . count }
403
+ assert_equal ( expected , Cpk ::Book . where ( author_id : book . author_id ) . group ( :author_id ) . count )
404
+ end
405
+
395
406
def test_should_group_by_summed_field_having_condition
396
407
c = Account . group ( :firm_id ) . having ( "sum(credit_limit) > 50" ) . sum ( :credit_limit )
397
408
assert_nil c [ 1 ]
You can’t perform that action at this time.
0 commit comments