Permalink
Browse files

Add tests for Relation#only.

  • Loading branch information...
1 parent 33412b6 commit e3246ef5b50d48aa86ee41a161b42611a936f4fb @miloops miloops committed Sep 9, 2010
Showing with 11 additions and 0 deletions.
  1. +11 −0 activerecord/test/cases/relations_test.rb
@@ -647,6 +647,17 @@ def test_except
assert_equal Post.all, all_posts.all
end
+ def test_only
+ relation = Post.where(:author_id => 1).order('id ASC').limit(1)
+ assert_equal [posts(:welcome)], relation.all
+
+ author_posts = relation.only(:where)
+ assert_equal Post.where(:author_id => 1).all, author_posts.all
+
+ all_posts = relation.only(:limit)
+ assert_equal Post.limit(1).all.first, all_posts.first
+ end
+
def test_anonymous_extension
relation = Post.where(:author_id => 1).order('id ASC').extending do
def author

0 comments on commit e3246ef

Please sign in to comment.