Skip to content

Commit

Permalink
Fix 'STI total_count with GROUP BY clause' test
Browse files Browse the repository at this point in the history
This test's data was built using a hash keyed by a name which was
included twice, so it would always pass as long as total_count builds a
valid query. Fixed by using a 2D array instead.
  • Loading branch information
bendilley committed May 29, 2020
1 parent ab8b111 commit ea18d30
Showing 1 changed file with 7 additions and 7 deletions.
Expand Up @@ -105,13 +105,13 @@ class ActiveRecordRelationMethodsTest < ActiveSupport::TestCase
end

test 'calculating STI total_count with GROUP BY clause' do
{
'Fenton' => Dog,
'Bob' => Dog,
'Garfield' => Cat,
'Bob' => Cat,
'Caine' => Insect
}.each { |name, type| type.create!(name: name) }
[
['Fenton', Dog],
['Bob', Dog],
['Garfield', Cat],
['Bob', Cat],
['Caine', Insect]
].each { |name, type| type.create!(name: name) }

assert_equal 3, Mammal.group(:name).page(1).total_count
end
Expand Down

0 comments on commit ea18d30

Please sign in to comment.