diff options
author | Bogdan Gusiev <agresso@gmail.com> | 2011-07-05 14:36:20 +0300 |
---|---|---|
committer | Bogdan Gusiev <agresso@gmail.com> | 2011-07-05 14:36:20 +0300 |
commit | e7bec4e435d05eb517f515a4661186ce8d088238 (patch) | |
tree | fc85f69a839e53efdb9662de91a249c860b634fe /activerecord/test | |
parent | 289b5253ce476410ff78a5f55248c5a4e6a60223 (diff) | |
download | rails-e7bec4e435d05eb517f515a4661186ce8d088238.tar.gz rails-e7bec4e435d05eb517f515a4661186ce8d088238.tar.bz2 rails-e7bec4e435d05eb517f515a4661186ce8d088238.zip |
Fixed AR::Relation#sum compatibility with Array#sum
In order make Relation behavior closer to Array
Made Relation#sum to accept block and delegate it to Array#sum
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/calculations_test.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index 56f6d795b6..224b3f3d1f 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -397,6 +397,10 @@ class CalculationsTest < ActiveRecord::TestCase Account.sum(:credit_limit, :from => 'accounts', :conditions => "credit_limit > 50") end + def test_sum_array_compatibility + assert_equal Account.sum(:credit_limit), Account.sum(&:credit_limit) + end + def test_average_with_from_option assert_equal Account.average(:credit_limit), Account.average(:credit_limit, :from => 'accounts') assert_equal Account.average(:credit_limit, :conditions => "credit_limit > 50"), |