diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-01-28 16:01:12 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-01-28 16:01:12 -0700 |
commit | 74c2961bd864f633c79c03e62c2cb142642201c5 (patch) | |
tree | 442b1f37ab6aa110d3d2a21a14c65b3a8dc9b327 /activerecord/test | |
parent | 9e42cf019f2417473e7dcbfcb885709fa2709f89 (diff) | |
download | rails-74c2961bd864f633c79c03e62c2cb142642201c5.tar.gz rails-74c2961bd864f633c79c03e62c2cb142642201c5.tar.bz2 rails-74c2961bd864f633c79c03e62c2cb142642201c5.zip |
Don't error when grouped calculations return 0 records
Fixes #18717
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/calculations_test.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index 299217214e..f47568f2f5 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -631,4 +631,9 @@ class CalculationsTest < ActiveRecord::TestCase assert_equal({ "has trinket" => part.id }, ShipPart.joins(:trinkets).group("ship_parts.name").sum(:id)) end + + def test_calculation_grouped_by_association_doesnt_error_when_no_records_have_association + Client.update_all(client_of: nil) + assert_equal({ nil => Client.count }, Client.group(:firm).count) + end end |