aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2010-06-23 13:10:53 -0300
committerJosé Valim <jose.valim@gmail.com>2010-06-24 11:41:55 +0200
commit5441e082f9478ddb3c676c681b09786f1391483c (patch)
treee6c0c734097109b0e159a27aa6a1e75933e73a91
parente061a12a156791c35bba092263ad216b1b938502 (diff)
downloadrails-5441e082f9478ddb3c676c681b09786f1391483c.tar.gz
rails-5441e082f9478ddb3c676c681b09786f1391483c.tar.bz2
rails-5441e082f9478ddb3c676c681b09786f1391483c.zip
Add tests for relation count. Fix other tests that were conceptually wrong.
[#4882 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
-rw-r--r--activerecord/test/cases/calculations_test.rb2
-rw-r--r--activerecord/test/cases/relations_test.rb6
2 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb
index 329dd7d761..2c9d23c80f 100644
--- a/activerecord/test/cases/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -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
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index 4316aa98d4..abf43cea98 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -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