Permalink
Browse files

Add Relation#all as an alias for to_a

  • Loading branch information...
1 parent a73fa93 commit feb8b20eb552eee678448233672733c6e7ca9571 @lifo lifo committed Dec 26, 2009
Showing with 8 additions and 0 deletions.
  1. +2 −0 activerecord/lib/active_record/relation.rb
  2. +6 −0 activerecord/test/cases/relations_test.rb
@@ -51,6 +51,8 @@ def to_a
records
end
+ alias all to_a
+
def first
@relation = @relation.take(1)
to_a.first
@@ -18,6 +18,12 @@ def test_scoped
assert_equal 4, topics.size
end
+ def test_scoped_all
+ topics = Topic.scoped.all
+ assert_kind_of Array, topics
+ assert_no_queries { assert_equal 4, topics.size }
+ end
+
def test_finding_with_conditions
assert_equal ["David"], Author.where(:name => 'David').map(&:name)
assert_equal ['Mary'], Author.where(["name = ?", 'Mary']).map(&:name)

0 comments on commit feb8b20

Please sign in to comment.