public
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/technoweenie/will_paginate.git
Search Repo:
big refactoring in view tests; rewrite most of them in much nicer way to 
test/view_test.rb
mislav (author)
Sun Apr 06 12:40:59 -0700 2008
commit  efe2c81322301bc0b1b62e211f199b7959b0dca3
tree    526996b892969741d2df0fe1f56b5c241fd84b53
parent  b00a298c02df8ab68e18bc107e41ce35533e1af1
...
21
22
23
24
 
25
26
27
...
21
22
23
 
24
25
26
27
0
@@ -21,7 +21,7 @@
0
       require 'will_paginate/view_helpers'
0
       ActionView::Base.class_eval { include ViewHelpers }
0
 
0
- if ActionController::Base.respond_to? :rescue_responses
0
+ if defined?(ActionController::Base) and ActionController::Base.respond_to? :rescue_responses
0
         ActionController::Base.rescue_responses['WillPaginate::InvalidPage'] = :not_found
0
       end
0
     end
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,127 +1 @@
0
-require 'helper'
0
-require 'will_paginate/array'
0
-
0
-class ArrayPaginationTest < Test::Unit::TestCase
0
- def test_simple
0
- collection = ('a'..'e').to_a
0
-
0
- [{ :page => 1, :per_page => 3, :expected => %w( a b c ) },
0
- { :page => 2, :per_page => 3, :expected => %w( d e ) },
0
- { :page => 1, :per_page => 5, :expected => %w( a b c d e ) },
0
- { :page => 3, :per_page => 5, :expected => [] },
0
- ].
0
- each do |conditions|
0
- expected = conditions.delete :expected
0
- assert_equal expected, collection.paginate(conditions)
0
- end
0
- end
0
-
0
- def test_defaults
0
- result = (1..50).to_a.paginate
0
- assert_equal 1, result.current_page
0
- assert_equal 30, result.size
0
- end
0
-
0
- def test_deprecated_api
0
- assert_raise(ArgumentError) { [].paginate(2) }
0
- assert_raise(ArgumentError) { [].paginate(2, 10) }
0
- end
0
-
0
- def test_total_entries_has_precedence
0
- result = %w(a b c).paginate :total_entries => 5
0
- assert_equal 5, result.total_entries
0
- end
0
-
0
- def test_argument_error_with_params_and_another_argument
0
- assert_raise ArgumentError do
0
- [].paginate({}, 5)
0
- end
0
- end
0
-
0
- def test_paginated_collection
0
- entries = %w(a b c)
0
- collection = create(2, 3, 10) do |pager|
0
- assert_equal entries, pager.replace(entries)
0
- end
0
-
0
- assert_equal entries, collection
0
- assert_respond_to_all collection, %w(total_pages each offset size current_page per_page total_entries)
0
- assert_kind_of Array, collection
0
- assert_instance_of Array, collection.entries
0
- assert_equal 3, collection.offset
0
- assert_equal 4, collection.total_pages
0
- assert !collection.out_of_bounds?
0
- end
0
-
0
- def test_out_of_bounds
0
- entries = create(2, 3, 2){}
0
- assert entries.out_of_bounds?
0
-
0
- entries = create(1, 3, 2){}
0
- assert !entries.out_of_bounds?
0
- end
0
-
0
- def test_guessing_total_count
0
- entries = create do |pager|
0
- # collection is shorter than limit
0
- pager.replace array
0
- end
0
- assert_equal 8, entries.total_entries
0
-
0
- entries = create(2, 5, 10) do |pager|
0
- # collection is shorter than limit, but we have an explicit count
0
- pager.replace array
0
- end
0
- assert_equal 10, entries.total_entries
0
-
0
- entries = create do |pager|
0
- # collection is the same as limit; we can't guess
0
- pager.replace array(5)
0
- end
0
- assert_equal nil, entries.total_entries
0
-
0
- entries = create do |pager|
0
- # collection is empty; we can't guess
0
- pager.replace array(0)
0
- end
0
- assert_equal nil, entries.total_entries
0
-
0
- entries = create(1) do |pager|
0
- # collection is empty and we're on page 1,
0
- # so the whole thing must be empty, too
0
- pager.replace array(0)
0
- end
0
- assert_equal 0, entries.total_entries
0
- end
0
-
0
- def test_invalid_page
0
- bad_input = [0, -1, nil, '', 'Schnitzel']
0
-
0
- bad_input.each do |bad|
0
- assert_raise(WillPaginate::InvalidPage) { create bad }
0
- end
0
- end
0
-
0
- def test_invalid_per_page_setting
0
- assert_raise(ArgumentError) { create(1, -1) }
0
- end
0
-
0
- def test_page_count_was_removed
0
- assert_raise(NoMethodError) { create.page_count }
0
- # It's `total_pages` now.
0
- end
0
-
0
- private
0
- def create(page = 2, limit = 5, total = nil, &block)
0
- if block_given?
0
- WillPaginate::Collection.create(page, limit, total, &block)
0
- else
0
- WillPaginate::Collection.new(page, limit, total)
0
- end
0
- end
0
-
0
- def array(size = 3)
0
- Array.new(size)
0
- end
0
-end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
0
@@ -1 +1,141 @@
0
+require 'helper'
0
+require 'will_paginate/array'
0
+
0
+class ArrayPaginationTest < Test::Unit::TestCase
0
+ def test_simple
0
+ collection = ('a'..'e').to_a
0
+
0
+ [{ :page => 1, :per_page => 3, :expected => %w( a b c ) },
0
+ { :page => 2, :per_page => 3, :expected => %w( d e ) },
0
+ { :page => 1, :per_page => 5, :expected => %w( a b c d e ) },
0
+ { :page => 3, :per_page => 5, :expected => [] },
0
+ ].
0
+ each do |conditions|
0
+ expected = conditions.delete :expected
0
+ assert_equal expected, collection.paginate(conditions)
0
+ end
0
+ end
0
+
0
+ def test_defaults
0
+ result = (1..50).to_a.paginate
0
+ assert_equal 1, result.current_page
0
+ assert_equal 30, result.size
0
+ end
0
+
0
+ def test_deprecated_api
0
+ assert_raise(ArgumentError) { [].paginate(2) }
0
+ assert_raise(ArgumentError) { [].paginate(2, 10) }
0
+ end
0
+
0
+ def test_total_entries_has_precedence
0
+ result = %w(a b c).paginate :total_entries => 5
0
+ assert_equal 5, result.total_entries
0
+ end
0
+
0
+ def test_argument_error_with_params_and_another_argument
0
+ assert_raise ArgumentError do
0
+ [].paginate({}, 5)
0
+ end
0
+ end
0
+
0
+ def test_paginated_collection
0
+ entries = %w(a b c)
0
+ collection = create(2, 3, 10) do |pager|
0
+ assert_equal entries, pager.replace(entries)
0
+ end
0
+
0
+ assert_equal entries, collection
0
+ assert_respond_to_all collection, %w(total_pages each offset size current_page per_page total_entries)
0
+ assert_kind_of Array, collection
0
+ assert_instance_of Array, collection.entries
0
+ assert_equal 3, collection.offset
0
+ assert_equal 4, collection.total_pages
0
+ assert !collection.out_of_bounds?
0
+ end
0
+
0
+ def test_previous_next_pages
0
+ collection = create(1, 1, 3)
0
+ assert_nil collection.previous_page
0
+ assert_equal 2, collection.next_page
0
+
0
+ collection = create(2, 1, 3)
0
+ assert_equal 1, collection.previous_page
0
+ assert_equal 3, collection.next_page
0
+
0
+ collection = create(3, 1, 3)
0
+ assert_equal 2, collection.previous_page
0
+ assert_nil collection.next_page
0
+ end
0
+
0
+ def test_out_of_bounds
0
+ entries = create(2, 3, 2){}
0
+ assert entries.out_of_bounds?
0
+
0
+ entries = create(1, 3, 2){}
0
+ assert !entries.out_of_bounds?
0
+ end
0
+
0
+ def test_guessing_total_count
0
+ entries = create do |pager|
0
+ # collection is shorter than limit
0
+ pager.replace array
0
+ end
0
+ assert_equal 8, entries.total_entries
0
+
0
+ entries = create(2, 5, 10) do |pager|
0
+ # collection is shorter than limit, but we have an explicit count
0
+ pager.replace array
0
+ end
0
+ assert_equal 10, entries.total_entries
0
+
0
+ entries = create do |pager|
0
+ # collection is the same as limit; we can't guess
0
+ pager.replace array(5)
0
+ end
0
+ assert_equal nil, entries.total_entries
0
+
0
+ entries = create do |pager|
0
+ # collection is empty; we can't guess
0
+ pager.replace array(0)
0
+ end
0
+ assert_equal nil, entries.total_entries
0
+
0
+ entries = create(1) do |pager|
0
+ # collection is empty and we're on page 1,
0
+ # so the whole thing must be empty, too
0
+ pager.replace array(0)
0
+ end
0
+ assert_equal 0, entries.total_entries
0
+ end
0
+
0
+ def test_invalid_page
0
+ bad_inputs = [0, -1, nil, '', 'Schnitzel']
0
+
0
+ bad_inputs.each do |bad|
0
+ assert_raise(WillPaginate::InvalidPage) { create bad }
0
+ end
0
+ end
0
+
0
+ def test_invalid_per_page_setting
0
+ assert_raise(ArgumentError) { create(1, -1) }
0
+ end
0
+
0
+ def test_page_count_was_removed
0
+ assert_raise(NoMethodError) { create.page_count }
0
+ # It's `total_pages` now.
0
+ end
0
+
0
+ private
0
+ def create(page = 2, limit = 5, total = nil, &block)
0
+ if block_given?
0
+ WillPaginate::Collection.create(page, limit, total, &block)
0
+ else
0
+ WillPaginate::Collection.new(page, limit, total)
0
+ end
0
+ end
0
+
0
+ def array(size = 3)
0
+ Array.new(size)
0
+ end
0
+end
...
13
14
15
 
 
 
 
 
 
 
 
 
 
 
 
16
17
18
...
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
0
@@ -13,6 +13,18 @@
0
       [method.to_s, method.to_sym].each { |m| assert_respond_to object, m }
0
     end
0
   end
0
+
0
+ def collect_deprecations
0
+ old_behavior = WillPaginate::Deprecation.behavior
0
+ deprecations = []
0
+ WillPaginate::Deprecation.behavior = Proc.new do |message, callstack|
0
+ deprecations << message
0
+ end
0
+ result = yield
0
+ [result, deprecations]
0
+ ensure
0
+ WillPaginate::Deprecation.behavior = old_behavior
0
+ end
0
 end
0
 
0
 # Wrap tests that use Mocha and skip if unavailable.
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,22 +1 @@
0
-require 'action_controller/test_process'
0
-
0
-module HTML
0
- class Node
0
- def inner_text
0
- children.map(&:inner_text).join('')
0
- end
0
- end
0
-
0
- class Text
0
- def inner_text
0
- self.to_s
0
- end
0
- end
0
-
0
- class Tag
0
- def inner_text
0
- childless?? '' : super
0
- end
0
- end
0
-end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
0
@@ -1 +1,68 @@
0
+require 'action_controller'
0
+require 'action_controller/test_process'
0
+
0
+require 'will_paginate'
0
+WillPaginate.enable_actionpack
0
+
0
+ActionController::Routing::Routes.draw do |map|
0
+ map.connect ':controller/:action/:id'
0
+end
0
+
0
+ActionController::Base.perform_caching = false
0
+
0
+class DummyRequest
0
+ def initialize
0
+ @get = true
0
+ end
0
+
0
+ def get?
0
+ @get
0
+ end
0
+
0
+ def post
0
+ @get = false
0
+ end
0
+
0
+ def symbolized_path_parameters
0
+ { :controller => 'foo', :action => 'bar' }
0
+ end
0
+
0
+ def relative_url_root
0
+ ''
0
+ end
0
+end
0
+
0
+class DummyController
0
+ attr_reader :request
0
+ attr_accessor :controller_name
0
+
0
+ def initialize
0
+ @request = DummyRequest.new
0
+ @url = ActionController::UrlRewriter.new(@request, {})
0
+ end
0
+
0
+ def url_for(params)
0
+ @url.rewrite(params)
0
+ end
0
+end
0
+
0
+module HTML
0
+ Node.class_eval do
0
+ def inner_text
0
+ children.map(&:inner_text).join('')
0
+ end
0
+ end
0
+
0
+ Text.class_eval do
0
+ def inner_text
0
+ self.to_s
0
+ end
0
+ end
0
+
0
+ Tag.class_eval do
0
+ def inner_text
0
+ childless?? '' : super
0
+ end
0
+ end
0
+end
...
1
2
3
 
4
5
6
7
8
9
10
11
12
13
14
15
16
...
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
...
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
...
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
...
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
...
1
 
 
2
3
 
 
 
 
 
 
 
 
 
4
5
6
...
15
16
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
19
20
...
26
27
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
30
31
32
...
81
82
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
86
87
...
107
108
109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
111
0
@@ -1,16 +1,6 @@
0
 require 'helper'
0
-require 'action_controller'
0
-require 'lib/html_inner_text'
0
+require 'lib/view_test_process'
0
 
0
-ActionController::Routing::Routes.draw do |map|
0
- map.connect ':controller/:action/:id'
0
-end
0
-
0
-ActionController::Base.perform_caching = false
0
-
0
-require 'will_paginate'
0
-WillPaginate.enable_actionpack
0
-
0
 class PaginationTest < Test::Unit::TestCase
0
   
0
   class DevelopersController < ActionController::Base
0
@@ -25,24 +15,6 @@
0
       render :inline => '<%= will_paginate @developers, @options %>'
0
     end
0
 
0
- def guess_collection_name
0
- @developers = session[:wp]
0
- @options = session[:wp_options]
0
-
0
- render :inline => '<%= will_paginate @options %>'
0
- end
0
-
0
- def paginated_section
0
- @developers = session[:wp]
0
- @options = session[:wp_options]
0
-
0
- render :inline => <<-ERB
0
- <% paginated_section @options do %>
0
- <%= content_tag :div, '', :id => "developers" %>
0
- <% end %>
0
- ERB
0
- end
0
-
0
     protected
0
       def rescue_errors(e) raise e end
0
       def rescue_action(e) raise e end
0
@@ -54,66 +26,6 @@
0
     @response = ActionController::TestResponse.new
0
     super
0
   end
0
-
0
- def test_will_paginate
0
- get :list_developers
0
-
0
- entries = assigns :developers
0
- assert entries
0
- assert_equal 4, entries.size
0
-
0
- assert_select 'div.pagination', 1, 'no main DIV' do |pagination|
0
- assert_select 'a[href]', 3 do |elements|
0
- validate_page_numbers [2,3,2], elements
0
- assert_select elements.last, ':last-child', "Next &raquo;"
0
- end
0
- assert_select 'span', 2
0
- assert_select 'span.disabled:first-child', "&laquo; Previous"
0
- assert_select 'span.current', entries.current_page.to_s
0
- assert_equal '&laquo; Previous 1 2 3 Next &raquo;', pagination.first.inner_text
0
- end
0
- end
0
-
0
- def test_will_paginate_with_options
0
- get :list_developers, { :page => 2 }, :wp => {
0
- :class => 'will_paginate', :prev_label => 'Prev', :next_label => 'Next'
0
- }
0
- assert_response :success
0
-
0
- entries = assigns :developers
0
- assert entries
0
- assert_equal 4, entries.size
0
-
0
- assert_select 'div.will_paginate', 1, 'no main DIV' do
0
- assert_select 'a[href]', 4 do |elements|
0
- validate_page_numbers [1,1,3,3], elements
0
- # test rel attribute values:
0
- assert_select elements[1], 'a', '1' do |link|
0
- assert_equal 'prev start', link.first['rel']
0
- end
0
- assert_select elements.first, 'a', "Prev" do |link|
0
- assert_equal 'prev start', link.first['rel']
0
- end
0
- assert_select elements.last, 'a', "Next" do |link|
0
- assert_equal 'next', link.first['rel']
0
- end
0
- end
0
- assert_select 'span.current', entries.current_page.to_s
0
- end
0
- end
0
-
0
- def test_will_paginate_without_container
0
- get :list_developers, {}, :wp => { :container => false }
0
- assert_select 'div.pagination', 0, 'no main DIV'
0
- assert_select 'a[href]', 3
0
- end
0
-
0
- def test_will_paginate_without_page_links
0
- get :list_developers, { :page => 2 }, :wp => { :page_links => false }
0
- assert_select 'a[href]', 2 do |elements|
0
- validate_page_numbers [1,3], elements
0
- end
0
- end
0
   
0
   def test_will_paginate_preserves_parameters_on_get
0
     get :list_developers, :foo => { :bar => 'baz' }
0
0
@@ -169,111 +81,7 @@
0
       assert_select 'span.current', entries.current_page.to_s
0
     end
0
   end
0
-
0
- def test_will_paginate_windows
0
- get :list_developers, { :page => 6, :per_page => 1 }, :wp => { :inner_window => 1 }
0
- assert_response :success
0
-
0
- entries = assigns :developers
0
- assert entries
0
- assert_equal 1, entries.size
0
-
0
- assert_select 'div.pagination', 1, 'no main DIV' do |pagination|
0
- assert_select 'a[href]', 8 do |elements|
0
- validate_page_numbers [5,1,2,5,7,10,11,7], elements
0
- assert_select elements.first, 'a', "&laquo; Previous"
0
- assert_select elements.last, 'a', "Next &raquo;"
0
- end
0
- assert_select 'span.current', entries.current_page.to_s
0
- assert_equal '&laquo; Previous 1 2 &hellip; 5 6 7 &hellip; 10 11 Next &raquo;', pagination.first.inner_text
0
- end
0
- end
0
-
0
- def test_will_paginate_eliminates_small_gaps
0
- get :list_developers, { :page => 6, :per_page => 1 }, :wp => { :inner_window => 2 }
0
- assert_response :success
0
-
0
- assert_select 'div.pagination', 1, 'no main DIV' do
0
- assert_select 'a[href]', 12 do |elements|
0
- validate_page_numbers [5,1,2,3,4,5,7,8,9,10,11,7], elements
0
- end
0
- end
0
- end
0
-
0
- def test_no_pagination
0
- get :list_developers, :per_page => 12
0
- entries = assigns :developers
0
- assert_equal 1, entries.total_pages
0
- assert_equal 11, entries.size
0
-
0
- assert_equal '', @response.body
0
- end
0
   
0
- def test_faulty_input_raises_error
0
- assert_raise WillPaginate::InvalidPage do
0
- get :list_developers, :page => 'foo'
0
- end
0
- end
0
-
0
- class LegacyCollection < WillPaginate::Collection
0
- alias :page_count :total_pages
0
- undef :total_pages
0
- end
0
-
0
- uses_mocha 'helper internals' do
0
- def test_collection_name_can_be_guessed
0
- collection = mock
0
- collection.expects(:total_pages).returns(1)
0
- get :guess_collection_name, {}, :wp => collection
0
- end
0
-
0
- def test_deprecation_notices_with_page_count
0
- collection = LegacyCollection.new 1, 1, 2
0
-
0
- assert_deprecated collection.class.name do
0
- get :guess_collection_name, {}, :wp => collection
0
- end
0
- end
0
- end
0
-
0
- def test_inferred_collection_name_raises_error_when_nil
0
- ex = assert_raise ArgumentError do
0
- get :guess_collection_name, {}, :wp => nil
0
- end
0
- assert ex.message.include?('@developers')
0
- end
0
-
0
- def test_setting_id_for_container
0
- get :list_developers
0
- assert_select 'div.pagination', 1 do |div|
0
- assert_nil div.first['id']
0
- end
0
- # magic ID
0
- get :list_developers, {}, :wp => { :id => true }
0
- assert_select 'div.pagination', 1 do |div|
0
- assert_equal 'fixnums_pagination', div.first['id']
0
- end
0
- # explicit ID
0
- get :list_developers, {}, :wp => { :id => 'custom_id' }
0
- assert_select 'div.pagination', 1 do |div|
0
- assert_equal 'custom_id', div.first['id']
0
- end
0
- end
0
-
0
- if ActionController::Base.respond_to? :rescue_responses
0
- def test_rescue_response_hook_presence
0
- assert_equal :not_found,
0
- DevelopersController.rescue_responses['WillPaginate::InvalidPage']
0
- end
0
- end
0
-
0
- def test_paginated_section
0
- collection = WillPaginate::Collection.new 1, 1, 2
0
- get :paginated_section, {}, :wp => collection, :wp_options => { :class => 'will_paginate' }
0
- assert_select 'div.will_paginate', 2
0
- assert_select 'div.will_paginate + div#developers', 1
0
- end
0
-
0
 protected
0
 
0
   def validate_page_numbers expected, links, param_name = :page
0
@@ -299,33 +107,6 @@
0
         assert_no_match pattern, el['href']
0
       end
0
     end
0
- end
0
-
0
- def collect_deprecations
0
- old_behavior = WillPaginate::Deprecation.behavior
0
- deprecations = []
0
- WillPaginate::Deprecation.behavior = Proc.new do |message, callstack|
0
- deprecations << message
0
- end
0
- result = yield
0
- [result, deprecations]
0
- ensure
0
- WillPaginate::Deprecation.behavior = old_behavior
0
- end
0
-end
0
-
0
-class ViewHelpersTest < Test::Unit::TestCase
0
- include WillPaginate::ViewHelpers
0
-
0
- def test_page_entries_info
0
- arr = ('a'..'z').to_a
0
- collection = arr.paginate :page => 2, :per_page => 5
0
- assert_equal %{Displaying entries <b>6&nbsp;-&nbsp;10</b> of <b>26</b> in total},
0
- page_entries_info(collection)
0
-
0
- collection = arr.paginate :page => 7, :per_page => 4
0
- assert_equal %{Displaying entries <b>25&nbsp;-&nbsp;26</b> of <b>26</b> in total},
0
- page_entries_info(collection)
0
   end
0
 end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
0
@@ -1 +1,225 @@
0
+require 'helper'
0
+require 'action_controller'
0
+require 'lib/view_test_process'
0
+
0
+class ViewTest < Test::Unit::TestCase
0
+
0
+ def setup
0
+ super
0
+ @controller = DummyController.new
0
+ @request = @controller.request