simple_record 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/simple_record.rb CHANGED
@@ -52,6 +52,10 @@ module SimpleRecord
52
52
  @@logging = false
53
53
  end
54
54
 
55
+ def self.logging?
56
+ @@logging
57
+ end
58
+
55
59
  def self.stats
56
60
  @@stats
57
61
  end
@@ -717,7 +721,7 @@ module SimpleRecord
717
721
  # to start at a specific row. So it will iterate from the first record and pull out the specific pages.
718
722
  def self.paginate(options={})
719
723
  # options = args.pop
720
- puts 'paginate options=' + options.inspect if @@logging
724
+ puts 'paginate options=' + options.inspect if SimpleRecord.logging?
721
725
  page = options[:page] || 1
722
726
  per_page = options[:per_page] || self.per_page || 50
723
727
  total = options[:total_entries]
data/test/test_base.rb CHANGED
@@ -38,6 +38,7 @@ class TestBase < Test::Unit::TestCase
38
38
  batch = []
39
39
  count.times do |i|
40
40
  mm = MyModel.new(:name=>"model_" + i.to_s)
41
+ mm.age = i
41
42
  batch << mm
42
43
  end
43
44
  MyModel.batch_save batch
@@ -16,11 +16,14 @@ class TestPagination < TestBase
16
16
  def test_paginate
17
17
  create_my_models(20)
18
18
 
19
+ i = 20
19
20
  (1..3).each do |page|
20
- models = MyModel.paginate :page=>page, :per_page=>5, :order=>"name"
21
+ models = MyModel.paginate :page=>page, :per_page=>5, :order=>"created desc"
21
22
  assert models.size == 5
22
23
  models.each do |m|
24
+ i -= 1
23
25
  puts m.name
26
+ assert m.age == i
24
27
  end
25
28
  end
26
29
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 2
8
- - 0
9
- version: 1.2.0
8
+ - 1
9
+ version: 1.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Travis Reeder
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-05-01 00:00:00 -07:00
19
+ date: 2010-05-08 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency