grape-kaminari 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/grape/kaminari/max_value_validator.rb +1 -1
- data/lib/grape/kaminari/version.rb +1 -1
- data/spec/kaminari_spec.rb +8 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0ae809ad4c135dcf91437d3e66be5aeade55263df274f958da45e3518643121
|
4
|
+
data.tar.gz: 6444fd46138c8e330a9c74254f27d0512ea861df07eb90cde07f070a1e43a0e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5633fb0d0acecfe2aa68eaff97e29aabddd087922b0ab17a439b26a6fd8ac3889f5f3c902dff54b1729bace30fe6c81c2972a1075785653ea0785b5326ad79e0
|
7
|
+
data.tar.gz: 25fbc7a3ad61bc457e237da7ccf9dfbced16c76b291cec006ed45ac9504fc9e208d3f5ac2e3f30f9f94396d7b157214f106aeec05bd8d121e1b6ee06e614025a
|
data/Gemfile.lock
CHANGED
@@ -3,7 +3,7 @@ module Grape
|
|
3
3
|
class MaxValueValidator < Grape::Validations::Base
|
4
4
|
def validate_param!(attr_name, params)
|
5
5
|
attr = params[attr_name]
|
6
|
-
return unless attr && @option && attr > @option
|
6
|
+
return unless attr.is_a?(Integer) && @option && attr > @option
|
7
7
|
|
8
8
|
raise Grape::Exceptions::Validation.new(
|
9
9
|
params: [@scope.full_name(attr_name)],
|
data/spec/kaminari_spec.rb
CHANGED
@@ -99,15 +99,21 @@ describe Grape::Kaminari do
|
|
99
99
|
|
100
100
|
it 'succeeds when :per_page is within :max_value' do
|
101
101
|
get('/', page: 1, per_page: 999)
|
102
|
-
expect(last_response.status).to eq
|
102
|
+
expect(last_response.status).to eq(200)
|
103
103
|
end
|
104
104
|
|
105
105
|
it 'ensures :per_page is within :max_value' do
|
106
106
|
get('/', page: 1, per_page: 1_000)
|
107
|
-
expect(last_response.status).to eq
|
107
|
+
expect(last_response.status).to eq(400)
|
108
108
|
expect(last_response.body).to match(/per_page must be less than or equal 999/)
|
109
109
|
end
|
110
110
|
|
111
|
+
it 'ensures :per_page is numeric' do
|
112
|
+
get('/', page: 1, per_page: 'foo')
|
113
|
+
expect(last_response.status).to eq(400)
|
114
|
+
expect(last_response.body).to match(/per_page is invalid/)
|
115
|
+
end
|
116
|
+
|
111
117
|
it 'defaults :offset to customized value' do
|
112
118
|
expect(params['offset'][:default]).to eq(9)
|
113
119
|
end
|