Permalink
Browse files

default to scoped order for paginated_each

  • Loading branch information...
1 parent f169dcc commit 02649d4999868d2753fe257cb1d0957ee70d5df2 @dcuddeback committed Mar 11, 2011
Showing with 9 additions and 1 deletion.
  1. +2 −1 lib/will_paginate/finder.rb
  2. +7 −0 test/finder_test.rb
@@ -97,7 +97,8 @@ def paginate(*args)
# See {Faking Cursors in ActiveRecord}[http://weblog.jamisbuck.org/2007/4/6/faking-cursors-in-activerecord]
# where Jamis Buck describes this and a more efficient way for MySQL.
def paginated_each(options = {})
- options = { :order => 'id', :page => 1 }.merge options
+ order = scope(:find, :order) || 'id'
+ options = { :order => order, :page => 1 }.merge options
options[:page] = options[:page].to_i
options[:total_entries] = 0 # skip the individual count queries
total = 0
View
@@ -284,6 +284,13 @@ def test_named_scope_with_include
assert_equal 1, entries.size
end
+ def test_paginated_each_with_scoped_order
+ paginated_developers = []
+ Developer.poor.paginated_each {|d| paginated_developers << d}
+
+ assert_equal Developer.poor.all, paginated_developers, 'should use scoped :order option'
+ end
+
## misc ##
def test_count_and_total_entries_options_are_mutually_exclusive

0 comments on commit 02649d4

Please sign in to comment.