will_paginate 2.3.16 → 3.0.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. data/CHANGELOG.rdoc +24 -80
  2. data/LICENSE +1 -1
  3. data/README.rdoc +125 -0
  4. data/Rakefile +26 -22
  5. data/lib/will_paginate/array.rb +25 -8
  6. data/lib/will_paginate/collection.rb +15 -28
  7. data/lib/will_paginate/core_ext.rb +26 -0
  8. data/lib/will_paginate/deprecation.rb +50 -0
  9. data/lib/will_paginate/finders/active_record.rb +158 -0
  10. data/lib/will_paginate/finders/active_resource.rb +51 -0
  11. data/lib/will_paginate/finders/base.rb +112 -0
  12. data/lib/will_paginate/finders/data_mapper.rb +30 -0
  13. data/lib/will_paginate/finders/sequel.rb +23 -0
  14. data/lib/will_paginate/finders.rb +9 -0
  15. data/lib/will_paginate/railtie.rb +26 -0
  16. data/lib/will_paginate/version.rb +5 -5
  17. data/lib/will_paginate/view_helpers/action_view.rb +142 -0
  18. data/lib/will_paginate/view_helpers/base.rb +126 -0
  19. data/lib/will_paginate/view_helpers/link_renderer.rb +130 -0
  20. data/lib/will_paginate/view_helpers/link_renderer_base.rb +83 -0
  21. data/lib/will_paginate/view_helpers/merb.rb +13 -0
  22. data/lib/will_paginate/view_helpers.rb +25 -436
  23. data/lib/will_paginate.rb +10 -84
  24. data/spec/collection_spec.rb +147 -0
  25. data/spec/console +8 -0
  26. data/spec/console_fixtures.rb +8 -0
  27. data/spec/database.yml +22 -0
  28. data/spec/finders/active_record_spec.rb +377 -0
  29. data/spec/finders/active_resource_spec.rb +52 -0
  30. data/spec/finders/activerecord_test_connector.rb +114 -0
  31. data/spec/finders/data_mapper_spec.rb +62 -0
  32. data/spec/finders/data_mapper_test_connector.rb +20 -0
  33. data/spec/finders/sequel_spec.rb +53 -0
  34. data/spec/finders/sequel_test_connector.rb +9 -0
  35. data/spec/finders_spec.rb +76 -0
  36. data/{test → spec}/fixtures/developer.rb +2 -3
  37. data/{test → spec}/fixtures/project.rb +2 -6
  38. data/{test → spec}/fixtures/projects.yml +1 -1
  39. data/{test → spec}/fixtures/reply.rb +1 -1
  40. data/spec/fixtures/topic.rb +7 -0
  41. data/spec/rcov.opts +2 -0
  42. data/spec/spec.opts +2 -0
  43. data/spec/spec_helper.rb +74 -0
  44. data/spec/tasks.rake +60 -0
  45. data/spec/view_helpers/action_view_spec.rb +345 -0
  46. data/spec/view_helpers/base_spec.rb +64 -0
  47. data/spec/view_helpers/link_renderer_base_spec.rb +84 -0
  48. data/spec/view_helpers/view_example_group.rb +103 -0
  49. metadata +60 -52
  50. data/README.md +0 -53
  51. data/lib/will_paginate/finder.rb +0 -264
  52. data/lib/will_paginate/i18n.rb +0 -29
  53. data/lib/will_paginate/locale/en.yml +0 -33
  54. data/lib/will_paginate/named_scope.rb +0 -170
  55. data/lib/will_paginate/named_scope_patch.rb +0 -37
  56. data/lib/will_paginate/per_page.rb +0 -27
  57. data/test/ci.rb +0 -56
  58. data/test/collection_test.rb +0 -160
  59. data/test/console +0 -8
  60. data/test/database.yml +0 -16
  61. data/test/finder_test.rb +0 -520
  62. data/test/fixtures/topic.rb +0 -12
  63. data/test/gemfiles/Gemfile.1.2 +0 -13
  64. data/test/gemfiles/Gemfile.1.2.lock +0 -39
  65. data/test/gemfiles/Gemfile.2.0 +0 -16
  66. data/test/gemfiles/Gemfile.2.0.lock +0 -28
  67. data/test/gemfiles/Gemfile.2.1 +0 -16
  68. data/test/gemfiles/Gemfile.2.1.lock +0 -28
  69. data/test/gemfiles/Gemfile.2.2 +0 -16
  70. data/test/gemfiles/Gemfile.2.2.lock +0 -28
  71. data/test/helper.rb +0 -34
  72. data/test/lib/activerecord_test_case.rb +0 -38
  73. data/test/lib/activerecord_test_connector.rb +0 -86
  74. data/test/lib/load_fixtures.rb +0 -12
  75. data/test/lib/view_test_process.rb +0 -186
  76. data/test/view_test.rb +0 -373
  77. /data/{test → spec}/fixtures/admin.rb +0 -0
  78. /data/{test → spec}/fixtures/developers_projects.yml +0 -0
  79. /data/{test → spec}/fixtures/replies.yml +0 -0
  80. /data/{test → spec}/fixtures/schema.rb +0 -0
  81. /data/{test → spec}/fixtures/topics.yml +0 -0
  82. /data/{test → spec}/fixtures/user.rb +0 -0
  83. /data/{test → spec}/fixtures/users.yml +0 -0
data/test/finder_test.rb DELETED
@@ -1,520 +0,0 @@
1
- require 'helper'
2
- require 'lib/activerecord_test_case'
3
-
4
- require 'will_paginate'
5
- WillPaginate.enable_activerecord
6
- WillPaginate.enable_named_scope
7
-
8
- class FinderTest < ActiveRecordTestCase
9
- fixtures :topics, :replies, :users, :projects, :developers_projects
10
-
11
- def test_new_methods_presence
12
- assert_respond_to_all Topic, %w(per_page paginate paginate_by_sql paginate_by_definition_in_class)
13
- end
14
-
15
- def test_simple_paginate
16
- assert_queries(1) do
17
- entries = Topic.paginate :page => nil
18
- assert_equal 1, entries.current_page
19
- assert_equal 1, entries.total_pages
20
- assert_equal 4, entries.size
21
- end
22
-
23
- assert_queries(2) do
24
- entries = Topic.paginate :page => 2
25
- assert_equal 1, entries.total_pages
26
- assert entries.empty?
27
- end
28
- end
29
-
30
- def test_per_page_setting
31
- assert_equal 30, Topic.per_page
32
- Topic.per_page = 12
33
- begin
34
- assert_equal 12, Topic.per_page
35
- ensure
36
- Topic.per_page = 30
37
- end
38
- assert_equal 10, Developer.per_page
39
- end
40
-
41
- def test_per_page_inheritance
42
- subclass = Class.new(Topic)
43
- assert_equal 30, subclass.per_page
44
- subclass.per_page = 12
45
- assert_equal 12, subclass.per_page
46
- assert_equal 30, Topic.per_page
47
- sub_subclass = Class.new(subclass)
48
- assert_equal 12, sub_subclass.per_page
49
- end
50
-
51
- def test_parameter_api
52
- # :page parameter in options is required!
53
- assert_raise(ArgumentError){ Topic.paginate }
54
- assert_raise(ArgumentError){ Topic.paginate({}) }
55
-
56
- # explicit :all should not break anything
57
- assert_equal Topic.paginate(:page => nil), Topic.paginate(:all, :page => 1)
58
-
59
- # :count could be nil and we should still not cry
60
- assert_nothing_raised { Topic.paginate :page => 1, :count => nil }
61
- end
62
-
63
- def test_counting_when_integer_has_length_method
64
- Integer.module_eval { def length; to_s.length; end }
65
- begin
66
- assert_equal 2, 11.length
67
- entries = Developer.paginate :page => 1, :per_page => 5
68
- assert_equal 11, entries.total_entries
69
- assert_equal 5, entries.size
70
- assert_equal 3, entries.total_pages
71
- ensure
72
- begin
73
- Integer.module_eval { remove_method :length }
74
- rescue
75
- end
76
- end
77
- end
78
-
79
- def test_paginate_with_per_page
80
- entries = Topic.paginate :page => 1, :per_page => 1
81
- assert_equal 1, entries.size
82
- assert_equal 4, entries.total_pages
83
-
84
- # Developer class has explicit per_page at 10
85
- entries = Developer.paginate :page => 1
86
- assert_equal 10, entries.size
87
- assert_equal 2, entries.total_pages
88
-
89
- entries = Developer.paginate :page => 1, :per_page => 5
90
- assert_equal 11, entries.total_entries
91
- assert_equal 5, entries.size
92
- assert_equal 3, entries.total_pages
93
- end
94
-
95
- def test_paginate_with_order
96
- entries = Topic.paginate :page => 1, :order => 'created_at desc'
97
- expected = [topics(:futurama), topics(:harvey_birdman), topics(:rails), topics(:ar)].reverse
98
- assert_equal expected, entries.to_a
99
- assert_equal 1, entries.total_pages
100
- end
101
-
102
- def test_paginate_with_conditions
103
- entries = Topic.paginate :page => 1, :conditions => ["created_at > ?", 30.minutes.ago]
104
- expected = [topics(:rails), topics(:ar)]
105
- assert_equal expected, entries.to_a
106
- assert_equal 1, entries.total_pages
107
- end
108
-
109
- def test_paginate_with_include_and_conditions
110
- entries = Topic.paginate \
111
- :page => 1,
112
- :include => :replies,
113
- :conditions => "replies.content LIKE 'Bird%' ",
114
- :per_page => 10
115
-
116
- expected = Topic.find :all,
117
- :include => 'replies',
118
- :conditions => "replies.content LIKE 'Bird%' ",
119
- :limit => 10
120
-
121
- assert_equal expected, entries.to_a
122
- assert_equal 1, entries.total_entries
123
- end
124
-
125
- def test_paginate_with_include_and_order
126
- entries = nil
127
- assert_queries(2) do
128
- entries = Topic.paginate \
129
- :page => 1,
130
- :include => :replies,
131
- :order => 'replies.created_at asc, topics.created_at asc',
132
- :per_page => 10
133
- end
134
-
135
- expected = Topic.find :all,
136
- :include => 'replies',
137
- :order => 'replies.created_at asc, topics.created_at asc',
138
- :limit => 10
139
-
140
- assert_equal expected, entries.to_a
141
- assert_equal 4, entries.total_entries
142
- end
143
-
144
- def test_paginate_associations_with_include
145
- entries, project = nil, projects(:active_record)
146
-
147
- assert_nothing_raised "THIS IS A BUG in Rails 1.2.3 that was fixed in [7326]. " +
148
- "Please upgrade to a newer version of Rails." do
149
- entries = project.topics.paginate \
150
- :page => 1,
151
- :include => :replies,
152
- :conditions => "replies.content LIKE 'Nice%' ",
153
- :per_page => 10
154
- end
155
-
156
- expected = Topic.find :all,
157
- :include => 'replies',
158
- :conditions => "project_id = #{project.id} AND replies.content LIKE 'Nice%' ",
159
- :limit => 10
160
-
161
- assert_equal expected, entries.to_a
162
- end
163
-
164
- def test_paginate_associations
165
- dhh = users :david
166
- expected_name_ordered = [projects(:action_controller), projects(:active_record)]
167
- expected_id_ordered = [projects(:active_record), projects(:action_controller)]
168
-
169
- assert_queries(2) do
170
- # with association-specified order
171
- entries = dhh.projects.paginate(:page => 1)
172
- assert_equal expected_name_ordered, entries
173
- assert_equal 2, entries.total_entries
174
- end
175
-
176
- # with explicit order
177
- entries = dhh.projects.paginate(:page => 1, :order => 'projects.id')
178
- assert_equal expected_id_ordered, entries
179
- assert_equal 2, entries.total_entries
180
-
181
- assert_nothing_raised { dhh.projects.find(:all, :order => 'projects.id', :limit => 4) }
182
- entries = dhh.projects.paginate(:page => 1, :order => 'projects.id', :per_page => 4)
183
- assert_equal expected_id_ordered, entries
184
-
185
- # has_many with implicit order
186
- topic = Topic.find(1)
187
- expected = [replies(:spam), replies(:witty_retort)]
188
- assert_equal expected.map(&:id).sort, topic.replies.paginate(:page => 1).map(&:id).sort
189
- assert_equal expected.reverse, topic.replies.paginate(:page => 1, :order => 'replies.id ASC')
190
- end
191
-
192
- def test_paginate_association_extension
193
- project = Project.find(:first)
194
-
195
- assert_queries(2) do
196
- entries = project.replies.paginate_recent :page => 1
197
- assert_equal [replies(:brave)], entries
198
- end
199
- end
200
-
201
- def test_paginate_with_joins
202
- entries = nil
203
-
204
- assert_queries(1) do
205
- entries = Developer.paginate :page => 1,
206
- :joins => 'LEFT JOIN developers_projects ON users.id = developers_projects.developer_id',
207
- :conditions => 'project_id = 1'
208
- assert_equal 2, entries.size
209
- developer_names = entries.map &:name
210
- assert developer_names.include?('David')
211
- assert developer_names.include?('Jamis')
212
- end
213
-
214
- assert_queries(1) do
215
- expected = entries.to_a
216
- entries = Developer.paginate :page => 1,
217
- :joins => 'LEFT JOIN developers_projects ON users.id = developers_projects.developer_id',
218
- :conditions => 'project_id = 1', :count => { :select => "users.id" }
219
- assert_equal expected, entries.to_a
220
- assert_equal 2, entries.total_entries
221
- end
222
- end
223
-
224
- def test_paginate_with_group
225
- entries = nil
226
- assert_queries(1) do
227
- entries = Developer.paginate :page => 1, :per_page => 10,
228
- :group => 'salary', :select => 'salary', :order => 'salary'
229
- end
230
-
231
- expected = [ users(:david), users(:jamis), users(:dev_10), users(:poor_jamis) ].map(&:salary).sort
232
- assert_equal expected, entries.map(&:salary)
233
- end
234
-
235
- def test_paginate_with_dynamic_finder
236
- expected = [replies(:witty_retort), replies(:spam)]
237
- assert_equal expected, Reply.paginate_by_topic_id(1, :page => 1, :order => :created_at)
238
-
239
- entries = Developer.paginate :conditions => { :salary => 100000 }, :page => 1, :per_page => 5
240
- assert_equal 8, entries.total_entries
241
- assert_equal entries, Developer.paginate_by_salary(100000, :page => 1, :per_page => 5)
242
-
243
- # dynamic finder + conditions
244
- entries = Developer.paginate_by_salary(100000, :page => 1,
245
- :conditions => ['id > ?', 6])
246
- assert_equal 4, entries.total_entries
247
- assert_equal (7..10).to_a, entries.map(&:id)
248
-
249
- assert_raises NoMethodError do
250
- Developer.paginate_by_inexistent_attribute 100000, :page => 1
251
- end
252
- end
253
-
254
- def test_scoped_paginate
255
- entries = Developer.with_poor_ones { Developer.paginate :page => 1 }
256
-
257
- assert_equal 2, entries.size
258
- assert_equal 2, entries.total_entries
259
- end
260
-
261
- ## named_scope ##
262
-
263
- def test_paginate_in_named_scope
264
- entries = Developer.poor.paginate :page => 1, :per_page => 1
265
-
266
- assert_equal 1, entries.size
267
- assert_equal 2, entries.total_entries
268
- end
269
-
270
- # fat chance I'll ever get to debugging and fixing this
271
- unless '1.8.7' == RUBY_VERSION and ActiveRecord::VERSION::STRING < '2.2'
272
- def test_paginate_in_named_scope_on_habtm_association
273
- project = projects(:active_record)
274
- assert_queries(2) do
275
- entries = project.developers.poor.paginate :page => 1, :per_page => 1
276
-
277
- assert_equal 1, entries.size, 'one developer should be found'
278
- assert_equal 1, entries.total_entries, 'only one developer should be found'
279
- end
280
- end
281
- end
282
-
283
- def test_paginate_in_named_scope_on_hmt_association
284
- project = projects(:active_record)
285
- expected = [replies(:brave)]
286
-
287
- assert_queries(2) do
288
- entries = project.replies.recent.paginate :page => 1, :per_page => 1
289
- assert_equal expected, entries
290
- assert_equal 1, entries.total_entries, 'only one reply should be found'
291
- end
292
- end
293
-
294
- def test_paginate_in_named_scope_on_has_many_association
295
- project = projects(:active_record)
296
- expected = [topics(:ar)]
297
-
298
- assert_queries(2) do
299
- entries = project.topics.mentions_activerecord.paginate :page => 1, :per_page => 1
300
- assert_equal expected, entries
301
- assert_equal 1, entries.total_entries, 'only one topic should be found'
302
- end
303
- end
304
-
305
- def test_named_scope_with_include
306
- project = projects(:active_record)
307
- entries = project.topics.with_replies_starting_with('AR ').paginate(:page => 1, :per_page => 1)
308
- assert_equal 1, entries.size
309
- end
310
-
311
- ## misc ##
312
-
313
- def test_count_and_total_entries_options_are_mutually_exclusive
314
- e = assert_raise ArgumentError do
315
- Developer.paginate :page => 1, :count => {}, :total_entries => 1
316
- end
317
- assert_match /exclusive/, e.to_s
318
- end
319
-
320
- def test_readonly
321
- assert_nothing_raised { Developer.paginate :readonly => true, :page => 1 }
322
- end
323
-
324
- # this functionality is temporarily removed
325
- def xtest_pagination_defines_method
326
- pager = "paginate_by_created_at"
327
- assert !User.methods.include_method?(pager), "User methods should not include `#{pager}` method"
328
- # paginate!
329
- assert 0, User.send(pager, nil, :page => 1).total_entries
330
- # the paging finder should now be defined
331
- assert User.methods.include_method?(pager), "`#{pager}` method should be defined on User"
332
- end
333
-
334
- # Is this Rails 2.0? Find out by testing find_all which was removed in [6998]
335
- unless ActiveRecord::Base.respond_to? :find_all
336
- def test_paginate_array_of_ids
337
- # AR finders also accept arrays of IDs
338
- # (this was broken in Rails before [6912])
339
- assert_queries(1) do
340
- entries = Developer.paginate((1..8).to_a, :per_page => 3, :page => 2, :order => 'id')
341
- assert_equal (4..6).to_a, entries.map(&:id)
342
- assert_equal 8, entries.total_entries
343
- end
344
- end
345
- end
346
-
347
- uses_mocha 'internals' do
348
- def test_implicit_all_with_dynamic_finders
349
- Topic.expects(:find_all_by_foo).returns([])
350
- Topic.expects(:count).returns(0)
351
- Topic.paginate_by_foo :page => 2
352
- end
353
-
354
- def test_guessing_the_total_count
355
- Topic.expects(:find).returns(Array.new(2))
356
- Topic.expects(:count).never
357
-
358
- entries = Topic.paginate :page => 2, :per_page => 4
359
- assert_equal 6, entries.total_entries
360
- end
361
-
362
- def test_guessing_that_there_are_no_records
363
- Topic.expects(:find).returns([])
364
- Topic.expects(:count).never
365
-
366
- entries = Topic.paginate :page => 1, :per_page => 4
367
- assert_equal 0, entries.total_entries
368
- end
369
-
370
- def test_extra_parameters_stay_untouched
371
- Topic.expects(:find).with(:all, {:foo => 'bar', :limit => 4, :offset => 0 }).returns(Array.new(5))
372
- Topic.expects(:count).with({:foo => 'bar'}).returns(1)
373
-
374
- Topic.paginate :foo => 'bar', :page => 1, :per_page => 4
375
- end
376
-
377
- def test_count_skips_select
378
- Developer.stubs(:find).returns([])
379
- Developer.expects(:count).with({}).returns(0)
380
- Developer.paginate :select => 'salary', :page => 2
381
- end
382
-
383
- def test_count_select_when_distinct
384
- Developer.stubs(:find).returns([])
385
- Developer.expects(:count).with(:select => 'DISTINCT salary').returns(0)
386
- Developer.paginate :select => 'DISTINCT salary', :page => 2
387
- end
388
-
389
- def test_count_with_scoped_select_when_distinct
390
- Developer.stubs(:find).returns([])
391
- Developer.expects(:count).with(:select => 'DISTINCT users.id').returns(0)
392
- Developer.distinct.paginate :page => 2
393
- end
394
-
395
- def test_should_use_scoped_finders_if_present
396
- # scope-out compatibility
397
- Topic.expects(:find_best).returns(Array.new(5))
398
- Topic.expects(:with_best).returns(1)
399
-
400
- Topic.paginate_best :page => 1, :per_page => 4
401
- end
402
-
403
- def test_paginate_by_sql
404
- sql = "SELECT * FROM users WHERE type = 'Developer' ORDER BY id"
405
- entries = Developer.paginate_by_sql(sql, :page => 2, :per_page => 3)
406
- assert_equal 11, entries.total_entries
407
- assert_equal [users(:dev_4), users(:dev_5), users(:dev_6)], entries
408
- end
409
-
410
- def test_paginate_by_sql_respects_total_entries_setting
411
- sql = "SELECT * FROM users"
412
- entries = Developer.paginate_by_sql(sql, :page => 1, :total_entries => 999)
413
- assert_equal 999, entries.total_entries
414
- end
415
-
416
- def test_paginate_by_sql_strips_order_by_when_counting
417
- Developer.expects(:find_by_sql).returns([])
418
- Developer.expects(:count_by_sql).with("SELECT COUNT(*) FROM (sql\n ) AS count_table").returns(0)
419
-
420
- Developer.paginate_by_sql "sql\n ORDER\nby foo, bar, `baz` ASC", :page => 2
421
- end
422
-
423
- # TODO: counts are still wrong
424
- def test_ability_to_use_with_custom_finders
425
- # acts_as_taggable defines find_tagged_with(tag, options)
426
- Topic.expects(:find_tagged_with).with('will_paginate', :offset => 5, :limit => 5).returns([])
427
- Topic.expects(:count).with({}).returns(0)
428
-
429
- Topic.paginate_tagged_with 'will_paginate', :page => 2, :per_page => 5
430
- end
431
-
432
- def test_array_argument_doesnt_eliminate_count
433
- ids = (1..8).to_a
434
- Developer.expects(:find_all_by_id).returns([])
435
- Developer.expects(:count).returns(0)
436
-
437
- Developer.paginate_by_id(ids, :per_page => 3, :page => 2, :order => 'id')
438
- end
439
-
440
- def test_paginating_finder_doesnt_mangle_options
441
- Developer.expects(:find).returns([])
442
- options = { :page => 1, :per_page => 2, :foo => 'bar' }
443
- options_before = options.dup
444
-
445
- Developer.paginate(options)
446
- assert_equal options_before, options
447
- end
448
-
449
- def test_paginate_by_sql_doesnt_change_original_query
450
- query = 'SQL QUERY'
451
- original_query = query.dup
452
- Developer.expects(:find_by_sql).returns([])
453
-
454
- Developer.paginate_by_sql query, :page => 1
455
- assert_equal original_query, query
456
- end
457
-
458
- def test_paginated_each
459
- collection = stub('collection', :size => 5, :empty? => false, :per_page => 5)
460
- collection.expects(:each).times(2).returns(collection)
461
- last_collection = stub('collection', :size => 4, :empty? => false, :per_page => 5)
462
- last_collection.expects(:each).returns(last_collection)
463
-
464
- params = { :order => 'id', :total_entries => 0 }
465
-
466
- Developer.expects(:paginate).with(params.merge(:page => 2)).returns(collection)
467
- Developer.expects(:paginate).with(params.merge(:page => 3)).returns(collection)
468
- Developer.expects(:paginate).with(params.merge(:page => 4)).returns(last_collection)
469
-
470
- assert_equal 14, Developer.paginated_each(:page => '2') { }
471
- end
472
-
473
- def test_paginated_each_with_named_scope
474
- assert_equal 2, Developer.poor.paginated_each(:per_page => 1) {
475
- assert_equal 11, Developer.count
476
- }
477
- end
478
-
479
- # detect ActiveRecord 2.1
480
- if ActiveRecord::Base.private_methods.include_method?(:references_eager_loaded_tables?)
481
- def test_removes_irrelevant_includes_in_count
482
- Developer.expects(:find).returns([1])
483
- Developer.expects(:count).with({}).returns(0)
484
-
485
- Developer.paginate :page => 1, :per_page => 1, :include => :projects
486
- end
487
-
488
- def test_doesnt_remove_referenced_includes_in_count
489
- Developer.expects(:find).returns([1])
490
- Developer.expects(:count).with({ :include => :projects, :conditions => 'projects.id > 2' }).returns(0)
491
-
492
- Developer.paginate :page => 1, :per_page => 1,
493
- :include => :projects, :conditions => 'projects.id > 2'
494
- end
495
- end
496
-
497
- def test_paginate_from
498
- result = Developer.paginate(:from => 'users', :page => 1, :per_page => 1)
499
- assert_equal 1, result.size
500
- end
501
-
502
- def test_hmt_with_include
503
- # ticket #220
504
- reply = projects(:active_record).replies.find(:first, :order => 'replies.id')
505
- assert_equal replies(:decisive), reply
506
-
507
- # ticket #223
508
- Project.find(1, :include => :replies)
509
-
510
- # I cannot reproduce any of the failures from those reports :(
511
- end
512
-
513
- def test_hmt_with_uniq
514
- project = Project.find(1)
515
- result = project.unique_replies.paginate :page => 1, :per_page => 1,
516
- :order => 'replies.id'
517
- assert_equal replies(:decisive), result.first
518
- end
519
- end
520
- end
@@ -1,12 +0,0 @@
1
- class Topic < ActiveRecord::Base
2
- has_many :replies, :dependent => :destroy, :order => 'replies.created_at DESC'
3
- belongs_to :project
4
-
5
- named_scope :mentions_activerecord, :conditions => ['topics.title LIKE ?', '%ActiveRecord%']
6
-
7
- named_scope :with_replies_starting_with, lambda { |text|
8
- { :conditions => "replies.content LIKE '#{text}%' ", :include => :replies }
9
- }
10
-
11
- def self.paginate_by_definition_in_class; end
12
- end
@@ -1,13 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gem 'rails', '~> 1.2.6'
4
-
5
- gem 'rake', '~> 0.8.7'
6
- gem 'mocha', '0.9.2'
7
- gem 'sqlite3-ruby', '1.3.1'
8
- gem 'mysql', :group => :mysql
9
-
10
- group :pg do
11
- gem 'postgres', :platforms => :ruby_18
12
- gem 'pg', :platforms => :ruby_19
13
- end
@@ -1,39 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- actionmailer (1.3.6)
5
- actionpack (= 1.13.6)
6
- actionpack (1.13.6)
7
- activesupport (= 1.4.4)
8
- actionwebservice (1.2.6)
9
- actionpack (= 1.13.6)
10
- activerecord (= 1.15.6)
11
- activerecord (1.15.6)
12
- activesupport (= 1.4.4)
13
- activesupport (1.4.4)
14
- mocha (0.9.2)
15
- rake
16
- mysql (2.8.1)
17
- pg (0.11.0)
18
- postgres (0.7.9.2008.01.28)
19
- rails (1.2.6)
20
- actionmailer (= 1.3.6)
21
- actionpack (= 1.13.6)
22
- actionwebservice (= 1.2.6)
23
- activerecord (= 1.15.6)
24
- activesupport (= 1.4.4)
25
- rake (>= 0.7.2)
26
- rake (0.8.7)
27
- sqlite3-ruby (1.3.1)
28
-
29
- PLATFORMS
30
- ruby
31
-
32
- DEPENDENCIES
33
- mocha (= 0.9.2)
34
- mysql
35
- pg
36
- postgres
37
- rails (~> 1.2.6)
38
- rake (~> 0.8.7)
39
- sqlite3-ruby (= 1.3.1)
@@ -1,16 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- rails_version = '~> 2.0.4'
4
-
5
- gem 'actionpack', rails_version
6
- gem 'activerecord', rails_version
7
-
8
- gem 'rake', '~> 0.8.7'
9
- gem 'mocha', '0.9.2'
10
- gem 'sqlite3-ruby', '1.3.1'
11
- gem 'mysql', :group => :mysql
12
-
13
- group :pg do
14
- gem 'postgres', :platforms => :ruby_18
15
- gem 'pg', :platforms => :ruby_19
16
- end
@@ -1,28 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- actionpack (2.0.5)
5
- activesupport (= 2.0.5)
6
- activerecord (2.0.5)
7
- activesupport (= 2.0.5)
8
- activesupport (2.0.5)
9
- mocha (0.9.2)
10
- rake
11
- mysql (2.8.1)
12
- pg (0.11.0)
13
- postgres (0.7.9.2008.01.28)
14
- rake (0.8.7)
15
- sqlite3-ruby (1.3.1)
16
-
17
- PLATFORMS
18
- ruby
19
-
20
- DEPENDENCIES
21
- actionpack (~> 2.0.4)
22
- activerecord (~> 2.0.4)
23
- mocha (= 0.9.2)
24
- mysql
25
- pg
26
- postgres
27
- rake (~> 0.8.7)
28
- sqlite3-ruby (= 1.3.1)
@@ -1,16 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- rails_version = '~> 2.1.0'
4
-
5
- gem 'actionpack', rails_version
6
- gem 'activerecord', rails_version
7
-
8
- gem 'rake', '~> 0.8.7'
9
- gem 'mocha', '0.9.2'
10
- gem 'sqlite3-ruby', '1.3.1'
11
- gem 'mysql', :group => :mysql
12
-
13
- group :pg do
14
- gem 'postgres', :platforms => :ruby_18
15
- gem 'pg', :platforms => :ruby_19
16
- end
@@ -1,28 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- actionpack (2.1.2)
5
- activesupport (= 2.1.2)
6
- activerecord (2.1.2)
7
- activesupport (= 2.1.2)
8
- activesupport (2.1.2)
9
- mocha (0.9.2)
10
- rake
11
- mysql (2.8.1)
12
- pg (0.11.0)
13
- postgres (0.7.9.2008.01.28)
14
- rake (0.8.7)
15
- sqlite3-ruby (1.3.1)
16
-
17
- PLATFORMS
18
- ruby
19
-
20
- DEPENDENCIES
21
- actionpack (~> 2.1.0)
22
- activerecord (~> 2.1.0)
23
- mocha (= 0.9.2)
24
- mysql
25
- pg
26
- postgres
27
- rake (~> 0.8.7)
28
- sqlite3-ruby (= 1.3.1)
@@ -1,16 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- rails_version = '~> 2.2.2'
4
-
5
- gem 'actionpack', rails_version
6
- gem 'activerecord', rails_version
7
-
8
- gem 'rake', '~> 0.8.7'
9
- gem 'mocha', '0.9.2'
10
- gem 'sqlite3-ruby', '1.3.1'
11
- gem 'mysql', :group => :mysql
12
-
13
- group :pg do
14
- gem 'postgres', :platforms => :ruby_18
15
- gem 'pg', :platforms => :ruby_19
16
- end