Permalink
Browse files

Merge pull request #14631 from laurocaetano/fix_count_with_order

Ignore order when doing count.
  • Loading branch information...
1 parent a0804f7 commit 890d4f3dd88a9a8d8f823ebd573aa96b99282bab @spastorino spastorino committed Apr 7, 2014
Showing with 14 additions and 0 deletions.
  1. +14 −0 activerecord/test/cases/calculations_test.rb
@@ -380,6 +380,20 @@ def test_count_with_too_many_parameters_raises
assert_raise(ArgumentError) { Account.count(1, 2, 3) }
end
+ def test_count_with_order
+ assert_equal 6, Account.order(:credit_limit).count
+ end
+
+ def test_count_with_reverse_order
+ assert_equal 6, Account.order(:credit_limit).reverse_order.count
+ end
+
+ def test_count_with_where_and_order
+ assert_equal 1, Account.where(firm_name: '37signals').count
+ assert_equal 1, Account.where(firm_name: '37signals').order(:firm_name).count
+ assert_equal 1, Account.where(firm_name: '37signals').order(:firm_name).reverse_order.count
+ end
+
def test_should_sum_expression
# Oracle adapter returns floating point value 636.0 after SUM
if current_adapter?(:OracleAdapter)

0 comments on commit 890d4f3

Please sign in to comment.