[Tests only] Add coverage for .count
calculations for a CPK model
This commit is contained in:
parent
795d524737
commit
cce2a18eb9
@ -392,6 +392,17 @@ def test_distinct_count_with_group_by_and_order_and_limit
|
||||
assert_equal({ 6 => 2 }, Account.group(:firm_id).distinct.order("1 DESC").limit(1).count)
|
||||
end
|
||||
|
||||
def test_count_for_a_composite_primary_key_model
|
||||
book = cpk_books(:cpk_great_author_first_book)
|
||||
assert_equal(1, Cpk::Book.where(author_id: book.author_id, number: book.number).count)
|
||||
end
|
||||
|
||||
def test_group_by_count_for_a_composite_primary_key_model
|
||||
book = cpk_books(:cpk_great_author_first_book)
|
||||
expected = { book.author_id => Cpk::Book.where(author_id: book.author_id).count }
|
||||
assert_equal(expected, Cpk::Book.where(author_id: book.author_id).group(:author_id).count)
|
||||
end
|
||||
|
||||
def test_should_group_by_summed_field_having_condition
|
||||
c = Account.group(:firm_id).having("sum(credit_limit) > 50").sum(:credit_limit)
|
||||
assert_nil c[1]
|
||||
|
Loading…
Reference in New Issue
Block a user