Permalink
Browse files

Make Model.all return an array rather than a relation for consistency…

…. Use Model.scoped to get a relation
  • Loading branch information...
1 parent 1efc8ed commit 81608cf8fa61973d65f24efbc4ae4931016888e7 @lifo lifo committed Dec 27, 2009
Showing with 9 additions and 3 deletions.
  1. +2 −2 activerecord/lib/active_record/base.rb
  2. +7 −1 activerecord/test/cases/base_test.rb
@@ -671,9 +671,9 @@ def all(*args)
options = args.extract_options!
if options.empty? && !scoped?(:find)
- arel_table
+ arel_table.to_a
else
- construct_finder_arel_with_includes(options)
+ construct_finder_arel_with_includes(options).to_a
end
end
@@ -1902,8 +1902,14 @@ def test_last
assert_equal Developer.find(:first, :order => 'id desc'), Developer.last
end
+ def test_all
+ developers = Developer.all
+ assert_kind_of Array, developers
+ assert_equal Developer.find(:all), developers
+ end
+
def test_all_with_conditions
- assert_equal Developer.find(:all, :order => 'id desc'), Developer.all.order('id desc').to_a
+ assert_equal Developer.find(:all, :order => 'id desc'), Developer.order('id desc').all
end
def test_find_ordered_last

0 comments on commit 81608cf

Please sign in to comment.