paginate-responder 2.0.0 → 2.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c0dad22bf8721f6e89e65e97553f7f7609b751851f657934943f29048065ff9
4
- data.tar.gz: 21505e8c7bb089eada2e3bb2845a0bfac72ee48c145efb9039c8825635d99314
3
+ metadata.gz: d3ebda3ad93e015f751f7232187fd433ee5b54cc9e9510e12968b5ade630d1e8
4
+ data.tar.gz: 21f34ffb96d3e184f58397f22386cddb95cef44a1a8f44e90fc8e542955652d4
5
5
  SHA512:
6
- metadata.gz: cf23527d28554dceb5d8ec790b1f3a7baff54d63541703c205c9de69acf8f0cd0037b63829df7985a500aa9a590f2a477a80d89b39c55e82acb4294f117bda4e
7
- data.tar.gz: ba948de0df39c1514a4ac6fdcae03ef616d0006a5e4337df6003ed8a02a74dd34a848dcdb6e1caa68c35b3bc623d740bada615bf798144ee1e3a4a40c2a9f409
6
+ metadata.gz: 4eb260f7dabd7a7a7511a4dfe2f03e6f2017cd77a56ac9f10d2ab785c423e1bbef6d5d08f507bb64d227e6aa7303724c4671dd54c4ddc8f42bc09f4961fe767a
7
+ data.tar.gz: 0f868e1b1e0ad53cb38cd9394ee40391dc25f7d1ba9efbcfbd520fa1829bb78b626f7b31b15490962998127e5e9c43109d25a6fa7f2c3c1e9847892570376168
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## 2.1.0 - 2019-02-28
10
+ ### Added
11
+ * Respond with pagination link headers to HEAD requests (#12)
12
+
9
13
  ## 2.0.0 - 2019-02-19
10
14
  ### Changed
11
15
  * Override respond, not to_format for compatibility with decorate-responder 2.0 (#17)
@@ -1,7 +1,7 @@
1
1
  module PaginateResponder
2
2
  module VERSION
3
3
  MAJOR = 2
4
- MINOR = 0
4
+ MINOR = 1
5
5
  PATCH = 0
6
6
  STAGE = nil
7
7
 
@@ -1,7 +1,7 @@
1
1
  module Responders
2
2
  module PaginateResponder
3
3
  def respond
4
- paginate! if get?
4
+ paginate! if get? || request.head?
5
5
 
6
6
  super
7
7
  end
@@ -21,14 +21,15 @@ RSpec.describe Responders::PaginateResponder, type: :controller do
21
21
  end
22
22
  end
23
23
 
24
+ let(:method) { :get }
24
25
  let(:response) { action.call; @response }
25
26
  let(:json) { JSON.parse response.body }
26
27
  let(:params) { {format: :json} }
27
28
 
28
29
  if ActionPack::VERSION::MAJOR >= 5
29
- let(:action) { -> { get :index, params: params } }
30
+ let(:action) { -> { send(method, :index, params: params) } }
30
31
  else
31
- let(:action) { -> { get :index, params } }
32
+ let(:action) { -> { send(method, :index, params) } }
32
33
  end
33
34
 
34
35
  context 'with AR resource' do
@@ -163,6 +164,15 @@ RSpec.describe Responders::PaginateResponder, type: :controller do
163
164
  it { is_expected.to include 'next' => 'http://test.host/index.json?page=2&per_page=50' }
164
165
  it { is_expected.to include 'last' => 'http://test.host/index.json?page=14&per_page=50' }
165
166
  end
167
+
168
+ context 'when method is HEAD' do
169
+ let(:method) { :head }
170
+
171
+ it { expect(subject.size).to eq 3 }
172
+ it { is_expected.to include 'first' => 'http://test.host/index.json?page=1' }
173
+ it { is_expected.to include 'next' => 'http://test.host/index.json?page=2' }
174
+ it { is_expected.to include 'last' => 'http://test.host/index.json?page=14' }
175
+ end
166
176
  end
167
177
 
168
178
  describe 'headers' do
@@ -172,5 +182,14 @@ RSpec.describe Responders::PaginateResponder, type: :controller do
172
182
  it { is_expected.to include 'X-Total-Count' => '676' }
173
183
  it { is_expected.to include 'X-Per-Page' => '50' }
174
184
  it { is_expected.to include 'X-Current-Page' => '1' }
185
+
186
+ context 'when method is HEAD' do
187
+ let(:method) { :head }
188
+
189
+ it { is_expected.to include 'X-Total-Pages' => '14' }
190
+ it { is_expected.to include 'X-Total-Count' => '676' }
191
+ it { is_expected.to include 'X-Per-Page' => '50' }
192
+ it { is_expected.to include 'X-Current-Page' => '1' }
193
+ end
175
194
  end
176
195
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paginate-responder
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-19 00:00:00.000000000 Z
11
+ date: 2019-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack-link_headers