files.com 1.0.75 → 1.0.76

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: 4e2a6520ef9479c777f51d37952731010b36853d48689a0bbc5709b335d0a3d2
4
- data.tar.gz: 206b9bcf98ff21c55323c5aa11ca0484a169b296049cbbd47b6bcc59e01f44e4
3
+ metadata.gz: e92b02ee9649f4629d85231228a8f1d6b59d81b458ee9c7503e3ed244f08f7c7
4
+ data.tar.gz: 1c06cb0d6e39863cbf38291043f757b30133dd27db493ff6183c61b9941bfb51
5
5
  SHA512:
6
- metadata.gz: b412285db5b0b86422a96528e84a20f63fea5c8d7179e9ed9aa5cd2254246aa6c23aa7da757cd08ac8854659f24ab211e93a3428b4da2e0cffdb09fefce9edd8
7
- data.tar.gz: d32fe9ba666a77ec11f4ec4b46e7c1cad7ae48b5911a817bfa43e47d2426bed60c167ff7786ab16ef53313ad68d2ea49dce714bc0eb532236fa6d038fd9eb449
6
+ metadata.gz: bb9cb7d730a80e1bb9aab05cb5927e813015b429f0d4f32724d7956fda0e78dc1ede4a5c616b6e630ff51c666e58f089a0f6edc757161e556cd8cd5f6c26e4cc
7
+ data.tar.gz: 2a9079000a415245a92ee1d809974a2cfe167cf46d16292c11de8ecdc5253328562f676171595a2c7e681dd7c8c5c06e193af77333a86e20471fef7d8bc63985
data/_VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.75
1
+ 1.0.76
@@ -77,7 +77,7 @@ module Files
77
77
  end
78
78
 
79
79
  def set_cursor
80
- params[:cursor] ||= @current_options[:client].cursor
80
+ params[:cursor] = @current_options[:client].cursor
81
81
  end
82
82
 
83
83
  def cursor
@@ -12,15 +12,34 @@ RSpec.describe Files::List do
12
12
  let(:per_page) { 3 }
13
13
 
14
14
  context "when response includes a cursor" do
15
- let(:client) { instance_double(Files::ApiClient, cursor: "XXX-XXX") }
15
+ let(:client) { instance_double(Files::ApiClient) }
16
+ let(:stubbed_cursors) {
17
+ [
18
+ '3',
19
+ '6',
20
+ nil
21
+ ]
22
+ }
23
+
24
+ before do
25
+ allow(client).to receive(:cursor).and_return(*stubbed_cursors)
26
+ end
16
27
 
17
28
  it "does not call the API until out of responses" do
18
29
  server_results = ('a'..'h').to_a
19
30
  times_block_yielded = 0
31
+ request_cursor = nil
32
+ response_cursor = nil
33
+
20
34
  list = described_class.new(ResourceWrapper, params) {
21
35
  times_block_yielded += 1
36
+ request_cursor = params[:cursor]
37
+ range_start = params[:cursor] ? params[:cursor].to_i : 0
38
+
39
+ response_data = server_results[range_start, per_page]
40
+ response_cursor = (range_start + per_page).to_s
22
41
  [
23
- instance_double(Files::Response, data: server_results.shift(per_page), http_status: 200),
42
+ instance_double(Files::Response, data: response_data, http_status: 200, http_headers: { "x-files-cursor" => response_cursor }),
24
43
  options
25
44
  ]
26
45
  }
@@ -29,15 +48,18 @@ RSpec.describe Files::List do
29
48
  expect(times_block_yielded).to eq(0)
30
49
  expect(results.next.object).to eq('a')
31
50
  expect(times_block_yielded).to eq(1)
51
+ expect(request_cursor).to eq(nil)
32
52
  expect(results.next.object).to eq('b')
33
53
  expect(results.next.object).to eq('c')
34
54
  expect(results.next.object).to eq('d')
35
55
  expect(times_block_yielded).to eq(2)
56
+ expect(request_cursor).to eq("3")
36
57
  expect(results.next.object).to eq('e')
37
58
  expect(results.next.object).to eq('f')
38
59
  expect(results.next.object).to eq('g')
39
60
  expect(results.next.object).to eq('h')
40
61
  expect(times_block_yielded).to eq(3)
62
+ expect(request_cursor).to eq("6")
41
63
  end
42
64
 
43
65
  it "stops calling the API once there is an error" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: files.com
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.75
4
+ version: 1.0.76
5
5
  platform: ruby
6
6
  authors:
7
7
  - files.com