mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Add tests for relation count. Fix other tests that were conceptually wrong.
[#4882 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
@@ -272,7 +272,7 @@ class CalculationsTest < ActiveRecord::TestCase
|
||||
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
|
||||
|
||||
@@ -483,7 +483,7 @@ class RelationTest < ActiveRecord::TestCase
|
||||
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
|
||||
@@ -619,4 +619,8 @@ class RelationTest < ActiveRecord::TestCase
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user