Skip to content

Commit

Permalink
Add tests for relation count. Fix other tests that were conceptually …
Browse files Browse the repository at this point in the history
…wrong.

[#4882 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
miloops authored and josevalim committed Jun 24, 2010
1 parent e061a12 commit 5441e08
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion activerecord/test/cases/calculations_test.rb
Expand Up @@ -272,7 +272,7 @@ def test_count_with_column_parameter
end

def test_count_with_column_and_options_parameter
assert_equal 2, Account.count(:firm_id, :conditions => "credit_limit = 50")
assert_equal 2, Account.count(:firm_id, :conditions => "credit_limit = 50 AND firm_id IS NOT NULL")
end

def test_count_with_no_parameters_isnt_deprecated
Expand Down
6 changes: 5 additions & 1 deletion activerecord/test/cases/relations_test.rb
Expand Up @@ -483,7 +483,7 @@ def test_count_explicit_columns
posts = Post.scoped

assert_equal [0], posts.select('comments_count').where('id is not null').group('id').order('id').count.values.uniq
assert_equal 0, posts.where('id is not null').select('comments_count').count
assert_equal 7, posts.where('id is not null').select('comments_count').count

assert_equal 7, posts.select('comments_count').count('id')
assert_equal 0, posts.select('comments_count').count
Expand Down Expand Up @@ -619,4 +619,8 @@ def test_named_extension
def test_order_by_relation_attribute
assert_equal Post.order(Post.arel_table[:title]).all, Post.order("title").all
end

def test_relations_limit_with_conditions_or_limit
assert_equal Post.limit(2).size, Post.limit(2).all.size
end
end

0 comments on commit 5441e08

Please sign in to comment.