aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/calculations_test.rb
diff options
context:
space:
mode:
authorDmitriy Kiriyenko <dmitriy.kiriyenko@gmail.com>2011-07-05 13:17:39 +0300
committerDmitriy Kiriyenko <dmitriy.kiriyenko@gmail.com>2011-07-27 16:48:15 +0300
commit9a298a162c16e019fe6971e563e7f4916e86ced6 (patch)
treecea21a5af39a744f182d5d419b9c76ca478557b2 /activerecord/test/cases/calculations_test.rb
parent24f0a872e660647fe1abf187748660a77da3fe0a (diff)
downloadrails-9a298a162c16e019fe6971e563e7f4916e86ced6.tar.gz
rails-9a298a162c16e019fe6971e563e7f4916e86ced6.tar.bz2
rails-9a298a162c16e019fe6971e563e7f4916e86ced6.zip
Fixed failing query when performing calculation with having based on select.
Diffstat (limited to 'activerecord/test/cases/calculations_test.rb')
-rw-r--r--activerecord/test/cases/calculations_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb
index 224b3f3d1f..42f98b3d42 100644
--- a/activerecord/test/cases/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -170,6 +170,13 @@ class CalculationsTest < ActiveRecord::TestCase
assert_equal 60, c[2]
end
+ def test_should_group_by_summed_field_having_condition_from_select
+ c = Account.select("MIN(credit_limit) AS min_credit_limit").group(:firm_id).having("min_credit_limit > 50").sum(:credit_limit)
+ assert_nil c[1]
+ assert_equal 60, c[2]
+ assert_equal 53, c[9]
+ end
+
def test_should_group_by_summed_association
c = Account.sum(:credit_limit, :group => :firm)
assert_equal 50, c[companies(:first_firm)]