diff options
author | Dmitriy Kiriyenko <dmitriy.kiriyenko@gmail.com> | 2011-07-05 13:17:39 +0300 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-08-13 16:22:20 -0700 |
commit | 4c873cbf367d82538dbac914e7eee05b3582b6f1 (patch) | |
tree | 3ad18ee9a1e6e1f3cc78d07addb88dd9ed1bfbff /activerecord/test/cases/calculations_test.rb | |
parent | 05f1a9bcc3c9223768187e2379b508638dfa19b6 (diff) | |
download | rails-4c873cbf367d82538dbac914e7eee05b3582b6f1.tar.gz rails-4c873cbf367d82538dbac914e7eee05b3582b6f1.tar.bz2 rails-4c873cbf367d82538dbac914e7eee05b3582b6f1.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.rb | 7 |
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)] |