omnis 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,7 +39,9 @@ module Omnis
39
39
  private
40
40
  def page
41
41
  return 0 unless @input_params.has_key? page_param_name
42
- return @input_params[page_param_name].to_i - 1
42
+ page_num = @input_params[page_param_name].to_i - 1
43
+ return 0 if page_num < 0
44
+ return page_num
43
45
  end
44
46
 
45
47
  def skip
@@ -1,3 +1,3 @@
1
1
  module Omnis
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -77,6 +77,11 @@ describe Omnis::MongoQuery do
77
77
  include Omnis::MongoQuery
78
78
  end
79
79
 
80
+ it "page 0 is treated like page 1" do
81
+ t = TestPageDefaultQuery.new({'page' => 0})
82
+ t.to_mongo.opts.should == { :limit => 20, :skip => 0, :fields => []}
83
+ end
84
+
80
85
  it "page default no page number given" do
81
86
  t = TestPageDefaultQuery.new({})
82
87
  t.to_mongo.opts.should == { :limit => 20, :skip => 0, :fields => []}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-19 00:00:00.000000000 Z
12
+ date: 2012-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport