From 12ac97707997f11ebda9d7527aaff14d079a2460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sun, 24 Jun 2012 06:42:41 -0700 Subject: Merge pull request #6842 from ernie/handle-non-strings-in-grouped-calculations Stop assuming strings for grouped calculations Conflicts: activerecord/lib/active_record/relation/calculations.rb --- activerecord/test/cases/calculations_test.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index 66c801ca75..e50de46f9e 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -67,6 +67,11 @@ class CalculationsTest < ActiveRecord::TestCase [1,6,2].each { |firm_id| assert c.keys.include?(firm_id) } end + def test_should_group_by_arel_attribute + c = Account.sum(:credit_limit, :group => Account.arel_table[:firm_id]) + [1,6,2].each { |firm_id| assert c.keys.include?(firm_id) } + end + def test_should_group_by_multiple_fields c = Account.count(:all, :group => ['firm_id', :credit_limit]) [ [nil, 50], [1, 50], [6, 50], [6, 55], [9, 53], [2, 60] ].each { |firm_and_limit| assert c.keys.include?(firm_and_limit) } -- cgit v1.2.3