grape-kaminari 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5282850782bd08c0a0719eaad85f84b406f1a7419b9755162f939dc7f7aa71bc
4
- data.tar.gz: 1fbe1503fe2149f82413c3e934452c85bfe190657077fbd1607e6a10beb812b2
3
+ metadata.gz: fbda16acc1309fb774a2c4567223c97726d212b321d6b0cccb199c3dc99457a0
4
+ data.tar.gz: 84435c93750e4879af86c18fd38e86f61e244eb722b95b27b5a4b84b276372b0
5
5
  SHA512:
6
- metadata.gz: 644acde6f381781e2ef22c484c72fd9c754f7b72382e88fb3047bd71686c9284f65ba4154d887ba66ed45dc164fbb2d1902dfefbcb9310ea42124b5f9146e8cc
7
- data.tar.gz: 12552dd5e9ce60c46726554e51cdffc01d1782b7a026f5298141f6c9b60e29ab0c05ce799eab01ae73acc14f458a08a6127b06d2357948ebc89b60681e5f3b71
6
+ metadata.gz: d2c03beecbb06ce1d537714392ad926e53b39e98d433ed2994ec3d1def516a679b69b7262928c3a00a0870690eaea094ccdee5dd6305cc10722eae1b7b4df14d
7
+ data.tar.gz: 6f7f41b703eb9e06db050636f3d68d23adeceb59113c43ff0f7da13d733e994a61c65ca34c9c1792fa6b50350686f5ff1574bc38a0c273564ac9284f1be22a2d
@@ -11,7 +11,7 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
  strategy:
13
13
  matrix:
14
- ruby-version: ["2.5", "2.6", "2.7", "3.0"]
14
+ ruby-version: ["2.7", "3.0", "3.1"]
15
15
  steps:
16
16
  - uses: actions/checkout@v2
17
17
  - uses: ruby/setup-ruby@v1
data/.gitignore CHANGED
@@ -14,3 +14,4 @@ spec/reports
14
14
  test/tmp
15
15
  test/version_tmp
16
16
  tmp
17
+ *~
data/.rubocop.yml CHANGED
@@ -6,7 +6,7 @@ inherit_mode:
6
6
  - Exclude
7
7
 
8
8
  AllCops:
9
- TargetRubyVersion: "2.5"
9
+ TargetRubyVersion: "2.7"
10
10
 
11
11
  Naming/FileName:
12
12
  Exclude:
data/Gemfile.lock CHANGED
@@ -1,32 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grape-kaminari (0.4.2)
5
- grape (>= 1.6.1, != 1.4.0)
4
+ grape-kaminari (0.4.3)
5
+ grape (>= 1.6.1)
6
6
  kaminari-grape
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (6.1.3.1)
11
+ activesupport (7.0.0)
12
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
13
  i18n (>= 1.6, < 2)
14
14
  minitest (>= 5.1)
15
15
  tzinfo (~> 2.0)
16
- zeitwerk (~> 2.3)
17
16
  ast (2.4.2)
18
17
  builder (3.2.4)
19
- concurrent-ruby (1.1.8)
20
- diff-lcs (1.4.4)
21
- dry-configurable (0.12.1)
18
+ concurrent-ruby (1.1.9)
19
+ diff-lcs (1.5.0)
20
+ dry-configurable (0.13.0)
22
21
  concurrent-ruby (~> 1.0)
23
- dry-core (~> 0.5, >= 0.5.0)
24
- dry-container (0.7.2)
22
+ dry-core (~> 0.6)
23
+ dry-container (0.9.0)
25
24
  concurrent-ruby (~> 1.0)
26
- dry-configurable (~> 0.1, >= 0.1.3)
27
- dry-core (0.5.0)
25
+ dry-configurable (~> 0.13, >= 0.13.0)
26
+ dry-core (0.7.1)
28
27
  concurrent-ruby (~> 1.0)
29
- dry-inflector (0.2.0)
28
+ dry-inflector (0.2.1)
30
29
  dry-logic (1.2.0)
31
30
  concurrent-ruby (~> 1.0)
32
31
  dry-core (~> 0.5, >= 0.5)
@@ -43,19 +42,19 @@ GEM
43
42
  mustermann-grape (~> 1.0.0)
44
43
  rack (>= 1.3.0)
45
44
  rack-accept
46
- i18n (1.8.10)
45
+ i18n (1.8.11)
47
46
  concurrent-ruby (~> 1.0)
48
- kaminari-core (1.2.1)
47
+ kaminari-core (1.2.2)
49
48
  kaminari-grape (1.0.1)
50
49
  grape
51
50
  kaminari-core (~> 1.0)
52
- minitest (5.14.4)
51
+ minitest (5.15.0)
53
52
  mustermann (1.1.1)
54
53
  ruby2_keywords (~> 0.0.1)
55
54
  mustermann-grape (1.0.1)
56
55
  mustermann (>= 1.0.0)
57
- parallel (1.20.1)
58
- parser (3.0.1.1)
56
+ parallel (1.21.0)
57
+ parser (3.1.0.0)
59
58
  ast (~> 2.4.1)
60
59
  rack (2.2.3)
61
60
  rack-accept (0.4.5)
@@ -63,8 +62,8 @@ GEM
63
62
  rack-test (1.1.0)
64
63
  rack (>= 1.0, < 3)
65
64
  rainbow (3.0.0)
66
- rake (13.0.3)
67
- regexp_parser (2.1.1)
65
+ rake (13.0.6)
66
+ regexp_parser (2.2.0)
68
67
  rexml (3.2.5)
69
68
  rspec (3.10.0)
70
69
  rspec-core (~> 3.10.0)
@@ -78,42 +77,35 @@ GEM
78
77
  rspec-mocks (3.10.2)
79
78
  diff-lcs (>= 1.2.0, < 2.0)
80
79
  rspec-support (~> 3.10.0)
81
- rspec-support (3.10.2)
82
- rubocop (1.13.0)
80
+ rspec-support (3.10.3)
81
+ rubocop (1.24.1)
83
82
  parallel (~> 1.10)
84
83
  parser (>= 3.0.0.0)
85
84
  rainbow (>= 2.2.2, < 4.0)
86
85
  regexp_parser (>= 1.8, < 3.0)
87
86
  rexml
88
- rubocop-ast (>= 1.2.0, < 2.0)
87
+ rubocop-ast (>= 1.15.1, < 2.0)
89
88
  ruby-progressbar (~> 1.7)
90
89
  unicode-display_width (>= 1.4.0, < 3.0)
91
- rubocop-ast (1.5.0)
90
+ rubocop-ast (1.15.1)
92
91
  parser (>= 3.0.1.1)
93
- rubocop-bsm (0.5.9)
92
+ rubocop-bsm (0.6.0)
94
93
  rubocop (~> 1.0)
95
94
  rubocop-performance
96
- rubocop-rails
97
95
  rubocop-rake
98
96
  rubocop-rspec
99
- rubocop-performance (1.11.1)
97
+ rubocop-performance (1.13.1)
100
98
  rubocop (>= 1.7.0, < 2.0)
101
99
  rubocop-ast (>= 0.4.0)
102
- rubocop-rails (2.9.1)
103
- activesupport (>= 4.2.0)
104
- rack (>= 1.1)
105
- rubocop (>= 0.90.0, < 2.0)
106
- rubocop-rake (0.5.1)
107
- rubocop
108
- rubocop-rspec (2.3.0)
100
+ rubocop-rake (0.6.0)
109
101
  rubocop (~> 1.0)
110
- rubocop-ast (>= 1.1.0)
102
+ rubocop-rspec (2.7.0)
103
+ rubocop (~> 1.19)
111
104
  ruby-progressbar (1.11.0)
112
- ruby2_keywords (0.0.4)
105
+ ruby2_keywords (0.0.5)
113
106
  tzinfo (2.0.4)
114
107
  concurrent-ruby (~> 1.0)
115
- unicode-display_width (2.0.0)
116
- zeitwerk (2.4.2)
108
+ unicode-display_width (2.1.0)
117
109
 
118
110
  PLATFORMS
119
111
  ruby
@@ -127,4 +119,4 @@ DEPENDENCIES
127
119
  rubocop-bsm
128
120
 
129
121
  BUNDLED WITH
130
- 2.1.4
122
+ 2.2.27
@@ -15,9 +15,9 @@ Gem::Specification.new do |spec|
15
15
  spec.files = `git ls-files -z`.split("\x0").reject {|f| f.start_with?('spec/') }
16
16
  spec.test_files = `git ls-files -z -- spec/*`.split("\x0")
17
17
  spec.require_paths = ['lib']
18
- spec.required_ruby_version = '>= 2.5'
18
+ spec.required_ruby_version = '>= 2.7'
19
19
 
20
- spec.add_runtime_dependency 'grape', '>= 1.6.1', '!= 1.4.0'
20
+ spec.add_runtime_dependency 'grape', '>= 1.6.1'
21
21
  spec.add_runtime_dependency 'kaminari-grape'
22
22
 
23
23
  spec.add_development_dependency 'bundler'
@@ -25,4 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency 'rake'
26
26
  spec.add_development_dependency 'rspec'
27
27
  spec.add_development_dependency 'rubocop-bsm'
28
+ spec.metadata['rubygems_mfa_required'] = 'true'
28
29
  end
@@ -1,5 +1,5 @@
1
1
  module Grape
2
2
  module Kaminari
3
- VERSION = '0.4.2'.freeze
3
+ VERSION = '0.4.3'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,94 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+
4
+ describe Grape::Kaminari do
5
+ let(:app) do
6
+ Class.new(Grape::API) do
7
+ include Grape::Kaminari
8
+
9
+ params do
10
+ use :pagination
11
+ end
12
+ get '' do
13
+ paginate(Kaminari.paginate_array((1..10).to_a))
14
+ end
15
+
16
+ params do
17
+ use :pagination, offset: false
18
+ end
19
+ get 'no-offset' do
20
+ paginate(Kaminari.paginate_array((1..10).to_a))
21
+ end
22
+
23
+ params do
24
+ use :pagination, offset: false
25
+ end
26
+ get 'no-count' do
27
+ paginate(Kaminari.paginate_array((1..10).to_a), without_count: true)
28
+ end
29
+
30
+ resource :sub do
31
+ params do
32
+ use :pagination, per_page: 2
33
+ end
34
+ get '/' do
35
+ paginate(Kaminari.paginate_array((1..10).to_a))
36
+ end
37
+ end
38
+ end
39
+ end
40
+ let(:json) { JSON.parse(last_response.body) }
41
+ let(:header) { last_response.header }
42
+
43
+ describe 'paginated helper' do
44
+ it 'returns the first page' do
45
+ get '/', page: 1, per_page: 3
46
+ expect(json).to eq [1, 2, 3]
47
+ end
48
+
49
+ it 'returns the second page' do
50
+ get '/', page: 2, per_page: 3
51
+ expect(json).to eq [4, 5, 6]
52
+ end
53
+
54
+ # This is here to ensure that Kaminari can handle `padding(false)`
55
+ # and still do the right thing.
56
+ it 'works when offset is false' do
57
+ get '/no-offset', page: 1, per_page: 3
58
+ expect(json).to eq [1, 2, 3]
59
+ end
60
+
61
+ it 'works without count' do
62
+ get '/no-count', page: 2, per_page: 3
63
+ expect(json).to eq [4, 5, 6]
64
+ expect(header).to include(
65
+ 'X-Per-Page' => '3',
66
+ 'X-Page' => '2',
67
+ 'X-Next-Page' => '3',
68
+ 'X-Prev-Page' => '1',
69
+ )
70
+ expect(header).not_to include(
71
+ 'X-Total',
72
+ 'X-Total-Pages',
73
+ )
74
+ end
75
+
76
+ it 'sets headers' do
77
+ get '/', page: 3, per_page: 2, offset: 1
78
+ expect(header).to include(
79
+ 'X-Total' => '10',
80
+ 'X-Total-Pages' => '5',
81
+ 'X-Per-Page' => '2',
82
+ 'X-Page' => '3',
83
+ 'X-Next-Page' => '4',
84
+ 'X-Prev-Page' => '2',
85
+ 'X-Offset' => '1',
86
+ )
87
+ end
88
+
89
+ it 'can be inherited' do
90
+ get '/sub', page: 1
91
+ expect(json).to eq [1, 2]
92
+ end
93
+ end
94
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-kaminari
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tymon Tobolski
@@ -18,9 +18,6 @@ dependencies:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: 1.6.1
21
- - - "!="
22
- - !ruby/object:Gem::Version
23
- version: 1.4.0
24
21
  type: :runtime
25
22
  prerelease: false
26
23
  version_requirements: !ruby/object:Gem::Requirement
@@ -28,9 +25,6 @@ dependencies:
28
25
  - - ">="
29
26
  - !ruby/object:Gem::Version
30
27
  version: 1.6.1
31
- - - "!="
32
- - !ruby/object:Gem::Version
33
- version: 1.4.0
34
28
  - !ruby/object:Gem::Dependency
35
29
  name: kaminari-grape
36
30
  requirement: !ruby/object:Gem::Requirement
@@ -136,12 +130,14 @@ files:
136
130
  - lib/grape/kaminari.rb
137
131
  - lib/grape/kaminari/max_value_validator.rb
138
132
  - lib/grape/kaminari/version.rb
133
+ - spec/grape/kaminari_params_spec.rb
139
134
  - spec/grape/kaminari_spec.rb
140
135
  - spec/spec_helper.rb
141
136
  homepage: ''
142
137
  licenses:
143
138
  - MIT
144
- metadata: {}
139
+ metadata:
140
+ rubygems_mfa_required: 'true'
145
141
  post_install_message:
146
142
  rdoc_options: []
147
143
  require_paths:
@@ -150,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
150
146
  requirements:
151
147
  - - ">="
152
148
  - !ruby/object:Gem::Version
153
- version: '2.5'
149
+ version: '2.7'
154
150
  required_rubygems_version: !ruby/object:Gem::Requirement
155
151
  requirements:
156
152
  - - ">="
@@ -162,5 +158,6 @@ signing_key:
162
158
  specification_version: 4
163
159
  summary: kaminari integration for grape
164
160
  test_files:
161
+ - spec/grape/kaminari_params_spec.rb
165
162
  - spec/grape/kaminari_spec.rb
166
163
  - spec/spec_helper.rb