aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/calculations_test.rb
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-07-17 20:16:35 +0000
committerRick Olson <technoweenie@gmail.com>2007-07-17 20:16:35 +0000
commita41305640722f1328ff51ce61c98371d4b648213 (patch)
tree8a3f8e482a2cc72b17d0937833a9803255e9343d /activerecord/test/calculations_test.rb
parentb549366216f6cb607bf06c19701912a2e0d1f77c (diff)
downloadrails-a41305640722f1328ff51ce61c98371d4b648213.tar.gz
rails-a41305640722f1328ff51ce61c98371d4b648213.tar.bz2
rails-a41305640722f1328ff51ce61c98371d4b648213.zip
Fix and properly document/test count(column_name) usage. Closes #8999 [lifofifo]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7192 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/calculations_test.rb')
-rw-r--r--activerecord/test/calculations_test.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/activerecord/test/calculations_test.rb b/activerecord/test/calculations_test.rb
index faa86c43f2..298a1d1878 100644
--- a/activerecord/test/calculations_test.rb
+++ b/activerecord/test/calculations_test.rb
@@ -227,12 +227,20 @@ class CalculationsTest < Test::Unit::TestCase
assert_raises(ArgumentError) { Company.send(:validate_calculation_options, :sum, :foo => :bar) }
assert_raises(ArgumentError) { Company.send(:validate_calculation_options, :count, :foo => :bar) }
end
-
+
def test_should_count_selected_field_with_include
assert_equal 6, Account.count(:distinct => true, :include => :firm)
assert_equal 4, Account.count(:distinct => true, :include => :firm, :select => :credit_limit)
end
-
+
+ def test_count_with_column_parameter
+ assert_equal 5, Account.count(:firm_id)
+ end
+
+ def test_count_with_column_and_options_parameter
+ assert_equal 2, Account.count(:firm_id, :conditions => "credit_limit = 50")
+ end
+
def test_count_with_no_parameters_isnt_deprecated
assert_not_deprecated { Account.count }
end