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 +4 -4
- data/_VERSION +1 -1
- data/lib/files.com/list.rb +1 -1
- data/spec/list_spec.rb +24 -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: e92b02ee9649f4629d85231228a8f1d6b59d81b458ee9c7503e3ed244f08f7c7
|
4
|
+
data.tar.gz: 1c06cb0d6e39863cbf38291043f757b30133dd27db493ff6183c61b9941bfb51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb9cb7d730a80e1bb9aab05cb5927e813015b429f0d4f32724d7956fda0e78dc1ede4a5c616b6e630ff51c666e58f089a0f6edc757161e556cd8cd5f6c26e4cc
|
7
|
+
data.tar.gz: 2a9079000a415245a92ee1d809974a2cfe167cf46d16292c11de8ecdc5253328562f676171595a2c7e681dd7c8c5c06e193af77333a86e20471fef7d8bc63985
|
data/_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.76
|
data/lib/files.com/list.rb
CHANGED
data/spec/list_spec.rb
CHANGED
@@ -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
|
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:
|
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
|