aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2010-09-09 15:27:10 -0300
committerEmilio Tagua <miloops@gmail.com>2010-09-09 15:27:10 -0300
commite3246ef5b50d48aa86ee41a161b42611a936f4fb (patch)
tree5d544deff422cb8dee6f6ab41abfe6103f1006c0 /activerecord
parent33412b6e160fce8c6497d5f0a73dcc4366a0d428 (diff)
downloadrails-e3246ef5b50d48aa86ee41a161b42611a936f4fb.tar.gz
rails-e3246ef5b50d48aa86ee41a161b42611a936f4fb.tar.bz2
rails-e3246ef5b50d48aa86ee41a161b42611a936f4fb.zip
Add tests for Relation#only.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/relations_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index b7112d0e37..9901f09f57 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -647,6 +647,17 @@ class RelationTest < ActiveRecord::TestCase
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