From a41305640722f1328ff51ce61c98371d4b648213 Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Tue, 17 Jul 2007 20:16:35 +0000 Subject: 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 --- activerecord/test/calculations_test.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'activerecord/test/calculations_test.rb') 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 -- cgit v1.2.3