public
Rubygem
Description: Most awesome pagination solution for Ruby
Homepage: http://github.com/mislav/will_paginate/wikis
Clone URL: git://github.com/mislav/will_paginate.git
remove ActiveSupport dependency from Finders::Common, add some specs for 
it
mislav (author)
Thu May 08 22:39:51 -0700 2008
commit  42c8e31fde4c554a56a99614dbd834c5c1da57ca
tree    1c062aef409df6a46c593612f48358f1bf303ec4
parent  ec4ad61f7a443a0d7f3ab84820b0933c9a5c8799
...
56
57
58
59
60
 
 
61
62
63
...
67
68
69
70
 
 
71
72
73
...
56
57
58
 
 
59
60
61
62
63
...
67
68
69
 
70
71
72
73
74
0
@@ -56,8 +56,8 @@ module WillPaginate
0
       protected
0
         
0
         def wp_parse_options(options) #:nodoc:
0
- raise ArgumentError, 'parameter hash expected' unless options.respond_to? :symbolize_keys
0
- options = options.symbolize_keys
0
+ raise ArgumentError, 'parameter hash expected' unless Hash === options
0
+ # options = options.symbolize_keys
0
           raise ArgumentError, ':page parameter required' unless options.key? :page
0
           
0
           if options[:count] and options[:total_entries]
0
@@ -67,7 +67,8 @@ module WillPaginate
0
           page = options[:page] || 1
0
           per_page = options[:per_page] || self.per_page
0
           total = options[:total_entries]
0
- [page, per_page, total]
0
+
0
+ return [page, per_page, total]
0
         end
0
         
0
     end
...
28
29
30
31
32
33
34
35
36
37
...
263
264
265
266
267
268
269
270
271
272
273
274
275
...
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
...
28
29
30
 
 
 
 
31
32
33
...
259
260
261
 
 
 
 
 
 
 
262
263
264
...
386
387
388
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
389
390
0
@@ -28,10 +28,6 @@ class FinderTest < ActiveRecordTestCase
0
   end
0
 
0
   def test_parameter_api
0
- # :page parameter in options is required!
0
- assert_raise(ArgumentError){ Topic.paginate }
0
- assert_raise(ArgumentError){ Topic.paginate({}) }
0
-
0
     # explicit :all should not break anything
0
     assert_equal Topic.paginate(:page => nil), Topic.paginate(:all, :page => 1)
0
 
0
@@ -263,13 +259,6 @@ class FinderTest < ActiveRecordTestCase
0
   end
0
 
0
   ## misc ##
0
-
0
- def test_count_and_total_entries_options_are_mutually_exclusive
0
- e = assert_raise ArgumentError do
0
- Developer.paginate :page => 1, :count => {}, :total_entries => 1
0
- end
0
- assert_match /exclusive/, e.to_s
0
- end
0
   
0
   def test_readonly
0
     assert_nothing_raised { Developer.paginate :readonly => true, :page => 1 }
0
@@ -397,20 +386,5 @@ class FinderTest < ActiveRecordTestCase
0
       Developer.paginate(options)
0
       assert_equal options, options_before
0
     end
0
-
0
- def test_paginated_each
0
- collection = stub('collection', :size => 5, :empty? => false, :per_page => 5)
0
- collection.expects(:each).times(2).returns(collection)
0
- last_collection = stub('collection', :size => 4, :empty? => false, :per_page => 5)
0
- last_collection.expects(:each).returns(last_collection)
0
-
0
- params = { :order => 'id', :total_entries => 0 }
0
-
0
- Developer.expects(:paginate).with(params.merge(:page => 2)).returns(collection)
0
- Developer.expects(:paginate).with(params.merge(:page => 3)).returns(collection)
0
- Developer.expects(:paginate).with(params.merge(:page => 4)).returns(last_collection)
0
-
0
- assert_equal 14, Developer.paginated_each(:page => '2') { }
0
- end
0
   end
0
 end

Comments

    No one has commented yet.