aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/calculations_test.rb
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2006-04-25 05:25:04 +0000
committerRick Olson <technoweenie@gmail.com>2006-04-25 05:25:04 +0000
commit4251662c1a4dbec8c69d4ab1b677950a0b4cfb58 (patch)
treeb3daa61acc884eddb42d1f0928842c21803b7638 /activerecord/test/calculations_test.rb
parentabc2dba1ed15d9b30900890fdf4dee10c4f60a02 (diff)
downloadrails-4251662c1a4dbec8c69d4ab1b677950a0b4cfb58.tar.gz
rails-4251662c1a4dbec8c69d4ab1b677950a0b4cfb58.tar.bz2
rails-4251662c1a4dbec8c69d4ab1b677950a0b4cfb58.zip
Allow all calculations to take the :include option, not just COUNT (closes #4840) [Rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4264 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/calculations_test.rb')
-rw-r--r--activerecord/test/calculations_test.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/test/calculations_test.rb b/activerecord/test/calculations_test.rb
index fbf830e9e6..c4e41b1dda 100644
--- a/activerecord/test/calculations_test.rb
+++ b/activerecord/test/calculations_test.rb
@@ -21,6 +21,16 @@ class CalculationsTest < Test::Unit::TestCase
assert_equal 60, Account.maximum(:credit_limit)
end
+ def test_should_get_maximum_of_field_with_include
+ assert_equal 50, Account.maximum(:credit_limit, :include => :firm, :conditions => "companies.name != 'Summit'")
+ end
+
+ def test_should_get_maximum_of_field_with_scoped_include
+ Account.with_scope :find => { :include => :firm, :conditions => "companies.name != 'Summit'" } do
+ assert_equal 50, Account.maximum(:credit_limit)
+ end
+ end
+
def test_should_get_minimum_of_field
assert_equal 50, Account.minimum(:credit_limit)
end
@@ -174,7 +184,6 @@ class CalculationsTest < Test::Unit::TestCase
Company.send(:validate_calculation_options, :count, :include => true)
end
- assert_raises(ArgumentError) { Company.send(:validate_calculation_options, :sum, :include => :posts) }
assert_raises(ArgumentError) { Company.send(:validate_calculation_options, :sum, :foo => :bar) }
assert_raises(ArgumentError) { Company.send(:validate_calculation_options, :count, :foo => :bar) }
end