diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-04-06 15:23:56 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-04-06 15:23:56 +0000 |
commit | 52d298a8bd5800d9149b0b288bd8a929110b5260 (patch) | |
tree | 7f6cb3528dd30c9593875c38da820125d4ba8427 /activerecord/test/calculations_test.rb | |
parent | 944ae628f529a5392a543a88186415e87f462009 (diff) | |
download | rails-52d298a8bd5800d9149b0b288bd8a929110b5260.tar.gz rails-52d298a8bd5800d9149b0b288bd8a929110b5260.tar.bz2 rails-52d298a8bd5800d9149b0b288bd8a929110b5260.zip |
Enable Limit/Offset in Calculations (closes #4558) [lmarlow@yahoo.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4185 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/calculations_test.rb')
-rw-r--r-- | activerecord/test/calculations_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/calculations_test.rb b/activerecord/test/calculations_test.rb index 0acc841712..fbf830e9e6 100644 --- a/activerecord/test/calculations_test.rb +++ b/activerecord/test/calculations_test.rb @@ -48,6 +48,18 @@ class CalculationsTest < Test::Unit::TestCase assert_equal [6, 2, 1], c.keys.compact end + def test_should_limit_calculation + c = Account.sum(:credit_limit, :conditions => "firm_id IS NOT NULL", + :group => :firm_id, :order => "firm_id", :limit => 2) + assert_equal [1, 2], c.keys.compact + end + + def test_should_limit_calculation_with_offset + c = Account.sum(:credit_limit, :conditions => "firm_id IS NOT NULL", + :group => :firm_id, :order => "firm_id", :limit => 2, :offset => 1) + assert_equal [2, 6], c.keys.compact + end + def test_should_group_by_summed_field_having_condition c = Account.sum(:credit_limit, :group => :firm_id, :having => 'sum(credit_limit) > 50') |