Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing pagination test

  • Loading branch information...
commit 7b5bd07cb4ab868b85218b0b8ee794c452e3a58e 1 parent cba0355
@celeduc celeduc authored
Showing with 16 additions and 5 deletions.
  1. +2 −0  Gemfile
  2. +1 −1  test/test_base.rb
  3. +13 −4 test/test_pagination.rb
View
2  Gemfile
@@ -7,7 +7,9 @@ gemspec
group :development do
gem 'jeweler', :git => 'git://github.com/technicalpickles/jeweler.git'
+ gem 'pry'
end
group :test do
gem 'test-unit'
+ gem 'activemodel'
end
View
2  test/test_base.rb
@@ -54,7 +54,7 @@ def reset_connection(options={})
def create_my_models(count)
batch = []
count.times do |i|
- mm = MyModel.new(:name=>"model_" + i.to_s)
+ mm = MyModel.new(:name=>"model_#{i}")
mm.age = i
batch << mm
end
View
17 test/test_pagination.rb
@@ -13,19 +13,28 @@
# Pagination is intended to be just like will_paginate.
class TestPagination < TestBase
+ def setup
+ super
+ MyModel.delete_domain
+ MyModel.create_domain
+ end
+
+ def teardown
+ MyModel.delete_domain
+ super
+ end
def test_paginate
create_my_models(20)
i = 20
(1..3).each do |page|
- models = MyModel.paginate :page=>page, :per_page=>5, :order=>"created desc", :consistent_read => true
- assert models.size == 5, "models.size=#{models.size}"
+ models = MyModel.paginate :page=>page, :per_page=>5, :order=>"age desc", :consistent_read => true
+ assert models.count == 5, "models.count=#{models.count}"
+ assert models.size == 20, "models.size=#{models.size}"
models.each do |m|
i -= 1
- puts m.name
assert m.age == i
end
end
end
-
end
Please sign in to comment.
Something went wrong with that request. Please try again.