public
Rubygem
Fork of mislav/will_paginate
Description: Most awesome pagination solution for Rails
Homepage: http://github.com/mislav/will_paginate/wikis
Clone URL: git://github.com/carllerche/will_paginate.git
test with rcov and bring it up to 100% test coverage (yeah!!)
mislav (author)
Sun Apr 06 20:02:06 -0700 2008
commit  f4a23208344e28c1d89b9d1d2bd68729b7c01800
tree    30230d605972e2e1a682ca5bc2bf3dfde87c9150
parent  f48248f8900a94a50325c6330b12f161c1ed064f
...
1
2
3
 
...
1
2
3
4
0
@@ -1,3 +1,4 @@
0
 /doc
0
 /rails
0
 *.gem
0
+/coverage
...
90
91
92
 
 
 
 
 
 
 
 
 
...
90
91
92
93
94
95
96
97
98
99
100
101
0
@@ -90,3 +90,12 @@ task :examples do
0
   %x(haml examples/index.haml examples/index.html)
0
   %x(sass examples/pagination.sass examples/pagination.css)
0
 end
0
+
0
+task :rcov do
0
+ excludes = %w( lib/will_paginate/named_scope*
0
+ lib/will_paginate/core_ext.rb
0
+ lib/will_paginate.rb
0
+ rails* )
0
+
0
+ system %[rcov -Itest:lib test/*.rb -x #{excludes.join(',')}]
0
+end
...
226
227
228
229
 
 
230
231
 
232
233
234
...
261
262
263
264
265
266
267
268
269
 
 
270
271
272
...
226
227
228
 
229
230
231
232
233
234
235
236
...
263
264
265
 
 
 
 
 
 
266
267
268
269
270
0
@@ -226,9 +226,11 @@ module WillPaginate
0
       if window_to > total_pages
0
         window_from -= window_to - total_pages
0
         window_to = total_pages
0
- elsif window_from < 1
0
+ end
0
+ if window_from < 1
0
         window_to += 1 - window_from
0
         window_from = 1
0
+ window_to = total_pages if window_to > total_pages
0
       end
0
       
0
       visible = (1..total_pages).to_a
0
@@ -261,12 +263,8 @@ module WillPaginate
0
         stringified_merge @url_params, @options[:params] if @options[:params]
0
         
0
         if param_name.index(/[^\w-]/)
0
- page_param = unless defined? CGIMethods
0
- ActionController::AbstractRequest
0
- else
0
- # Rails 1.2
0
- CGIMethods
0
- end.parse_query_parameters("#{param_name}=#{page}")
0
+ page_param = (defined?(CGIMethods) ? CGIMethods : ActionController::AbstractRequest).
0
+ parse_query_parameters("#{param_name}=#{page}")
0
           
0
           stringified_merge @url_params, page_param
0
         else
...
220
221
222
 
 
223
224
225
...
260
261
262
 
 
 
 
 
 
 
 
 
263
264
265
...
220
221
222
223
224
225
226
227
...
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
0
@@ -220,6 +220,8 @@ class FinderTest < ActiveRecordTestCase
0
     assert_equal 2, entries.size
0
     assert_equal 2, entries.total_entries
0
   end
0
+
0
+ ## named_scope ##
0
   
0
   def test_paginate_in_named_scope
0
     entries = Developer.poor.paginate :page => 1, :per_page => 1
0
@@ -260,6 +262,15 @@ class FinderTest < ActiveRecordTestCase
0
     end
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
   end

Comments

    No one has commented yet.