gocardless_pro 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/circle.yml +11 -3
- data/demo.rb +3 -3
- data/gocardless_pro.gemspec +6 -6
- data/lib/gocardless_pro.rb +2 -1
- data/lib/gocardless_pro/api_service.rb +3 -2
- data/lib/gocardless_pro/client.rb +6 -6
- data/lib/gocardless_pro/error.rb +4 -4
- data/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb +4 -4
- data/lib/gocardless_pro/request.rb +2 -2
- data/lib/gocardless_pro/resources/bank_details_lookup.rb +1 -0
- data/lib/gocardless_pro/resources/creditor.rb +1 -0
- data/lib/gocardless_pro/resources/creditor_bank_account.rb +1 -0
- data/lib/gocardless_pro/resources/customer.rb +1 -0
- data/lib/gocardless_pro/resources/customer_bank_account.rb +1 -0
- data/lib/gocardless_pro/resources/event.rb +1 -0
- data/lib/gocardless_pro/resources/mandate.rb +1 -0
- data/lib/gocardless_pro/resources/mandate_pdf.rb +1 -0
- data/lib/gocardless_pro/resources/payment.rb +1 -0
- data/lib/gocardless_pro/resources/payout.rb +1 -0
- data/lib/gocardless_pro/resources/redirect_flow.rb +1 -0
- data/lib/gocardless_pro/resources/refund.rb +1 -0
- data/lib/gocardless_pro/resources/subscription.rb +1 -0
- data/lib/gocardless_pro/services/base_service.rb +1 -1
- data/lib/gocardless_pro/version.rb +1 -1
- data/spec/api_service_spec.rb +49 -49
- data/spec/client_spec.rb +1 -1
- data/spec/error_spec.rb +13 -13
- data/spec/middlewares/raise_gocardless_errors_spec.rb +15 -16
- data/spec/resources/bank_details_lookup_spec.rb +18 -18
- data/spec/resources/creditor_bank_account_spec.rb +46 -46
- data/spec/resources/creditor_spec.rb +42 -42
- data/spec/resources/customer_bank_account_spec.rb +48 -48
- data/spec/resources/customer_spec.rb +42 -42
- data/spec/resources/event_spec.rb +18 -18
- data/spec/resources/mandate_pdf_spec.rb +18 -18
- data/spec/resources/mandate_spec.rb +54 -54
- data/spec/resources/payment_spec.rb +54 -54
- data/spec/resources/payout_spec.rb +18 -18
- data/spec/resources/redirect_flow_spec.rb +36 -36
- data/spec/resources/refund_spec.rb +42 -42
- data/spec/resources/subscription_spec.rb +48 -48
- data/spec/response_spec.rb +1 -2
- data/spec/services/bank_details_lookups_service_spec.rb +25 -25
- data/spec/services/creditor_bank_accounts_service_spec.rb +86 -86
- data/spec/services/creditors_service_spec.rb +87 -87
- data/spec/services/customer_bank_accounts_service_spec.rb +95 -95
- data/spec/services/customers_service_spec.rb +87 -87
- data/spec/services/events_service_spec.rb +49 -49
- data/spec/services/mandate_pdfs_service_spec.rb +25 -25
- data/spec/services/mandates_service_spec.rb +103 -103
- data/spec/services/payments_service_spec.rb +103 -103
- data/spec/services/payouts_service_spec.rb +49 -49
- data/spec/services/redirect_flows_service_spec.rb +52 -52
- data/spec/services/refunds_service_spec.rb +87 -87
- data/spec/services/subscriptions_service_spec.rb +95 -95
- metadata +10 -10
@@ -16,30 +16,30 @@ describe GoCardlessPro::Services::MandatePdfsService do
|
|
16
16
|
{
|
17
17
|
|
18
18
|
'expires_at' => 'expires_at-input',
|
19
|
-
'url' => 'url-input'
|
19
|
+
'url' => 'url-input',
|
20
20
|
}
|
21
21
|
end
|
22
22
|
|
23
23
|
before do
|
24
|
-
stub_request(:post, %r{.*api.gocardless.com/mandate_pdfs})
|
25
|
-
|
24
|
+
stub_request(:post, %r{.*api.gocardless.com/mandate_pdfs}).
|
25
|
+
with(
|
26
26
|
body: {
|
27
27
|
'mandate_pdfs' => {
|
28
28
|
|
29
29
|
'expires_at' => 'expires_at-input',
|
30
|
-
'url' => 'url-input'
|
31
|
-
}
|
30
|
+
'url' => 'url-input',
|
31
|
+
},
|
32
32
|
}
|
33
|
-
)
|
34
|
-
|
33
|
+
).
|
34
|
+
to_return(
|
35
35
|
body: {
|
36
36
|
'mandate_pdfs' =>
|
37
37
|
|
38
38
|
{
|
39
39
|
|
40
40
|
'expires_at' => 'expires_at-input',
|
41
|
-
'url' => 'url-input'
|
42
|
-
}
|
41
|
+
'url' => 'url-input',
|
42
|
+
},
|
43
43
|
|
44
44
|
}.to_json,
|
45
45
|
headers: response_headers
|
@@ -54,19 +54,19 @@ describe GoCardlessPro::Services::MandatePdfsService do
|
|
54
54
|
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
|
55
55
|
|
56
56
|
it 'retries timeouts' do
|
57
|
-
stub = stub_request(:post, %r{.*api.gocardless.com/mandate_pdfs})
|
58
|
-
|
57
|
+
stub = stub_request(:post, %r{.*api.gocardless.com/mandate_pdfs}).
|
58
|
+
to_timeout.then.to_return(status: 200, headers: response_headers)
|
59
59
|
|
60
60
|
post_create_response
|
61
61
|
expect(stub).to have_been_requested.twice
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'retries 5XX errors' do
|
65
|
-
stub = stub_request(:post, %r{.*api.gocardless.com/mandate_pdfs})
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
65
|
+
stub = stub_request(:post, %r{.*api.gocardless.com/mandate_pdfs}).
|
66
|
+
to_return(status: 502,
|
67
|
+
headers: { 'Content-Type' => 'text/html' },
|
68
|
+
body: '<html><body>Response from Cloudflare</body></html>').
|
69
|
+
then.to_return(status: 200, headers: response_headers)
|
70
70
|
|
71
71
|
post_create_response
|
72
72
|
expect(stub).to have_been_requested.twice
|
@@ -84,9 +84,9 @@ describe GoCardlessPro::Services::MandatePdfsService do
|
|
84
84
|
type: 'validation_failed',
|
85
85
|
code: 422,
|
86
86
|
errors: [
|
87
|
-
{ message: 'test error message', field: 'test_field' }
|
88
|
-
]
|
89
|
-
}
|
87
|
+
{ message: 'test error message', field: 'test_field' },
|
88
|
+
],
|
89
|
+
},
|
90
90
|
}.to_json,
|
91
91
|
headers: response_headers,
|
92
92
|
status: 422
|
@@ -105,7 +105,7 @@ describe GoCardlessPro::Services::MandatePdfsService do
|
|
105
105
|
{
|
106
106
|
|
107
107
|
'expires_at' => 'expires_at-input',
|
108
|
-
'url' => 'url-input'
|
108
|
+
'url' => 'url-input',
|
109
109
|
}
|
110
110
|
end
|
111
111
|
|
@@ -120,11 +120,11 @@ describe GoCardlessPro::Services::MandatePdfsService do
|
|
120
120
|
message: 'A resource has already been created with this idempotency key',
|
121
121
|
reason: 'idempotent_creation_conflict',
|
122
122
|
links: {
|
123
|
-
conflicting_resource_id: id
|
124
|
-
}
|
125
|
-
}
|
126
|
-
]
|
127
|
-
}
|
123
|
+
conflicting_resource_id: id,
|
124
|
+
},
|
125
|
+
},
|
126
|
+
],
|
127
|
+
},
|
128
128
|
}.to_json,
|
129
129
|
headers: response_headers,
|
130
130
|
status: 409
|
@@ -23,13 +23,13 @@ describe GoCardlessPro::Services::MandatesService do
|
|
23
23
|
'payments_require_approval' => 'payments_require_approval-input',
|
24
24
|
'reference' => 'reference-input',
|
25
25
|
'scheme' => 'scheme-input',
|
26
|
-
'status' => 'status-input'
|
26
|
+
'status' => 'status-input',
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
30
30
|
before do
|
31
|
-
stub_request(:post, %r{.*api.gocardless.com/mandates})
|
32
|
-
|
31
|
+
stub_request(:post, %r{.*api.gocardless.com/mandates}).
|
32
|
+
with(
|
33
33
|
body: {
|
34
34
|
'mandates' => {
|
35
35
|
|
@@ -41,11 +41,11 @@ describe GoCardlessPro::Services::MandatesService do
|
|
41
41
|
'payments_require_approval' => 'payments_require_approval-input',
|
42
42
|
'reference' => 'reference-input',
|
43
43
|
'scheme' => 'scheme-input',
|
44
|
-
'status' => 'status-input'
|
45
|
-
}
|
44
|
+
'status' => 'status-input',
|
45
|
+
},
|
46
46
|
}
|
47
|
-
)
|
48
|
-
|
47
|
+
).
|
48
|
+
to_return(
|
49
49
|
body: {
|
50
50
|
'mandates' =>
|
51
51
|
|
@@ -59,8 +59,8 @@ describe GoCardlessPro::Services::MandatesService do
|
|
59
59
|
'payments_require_approval' => 'payments_require_approval-input',
|
60
60
|
'reference' => 'reference-input',
|
61
61
|
'scheme' => 'scheme-input',
|
62
|
-
'status' => 'status-input'
|
63
|
-
}
|
62
|
+
'status' => 'status-input',
|
63
|
+
},
|
64
64
|
|
65
65
|
}.to_json,
|
66
66
|
headers: response_headers
|
@@ -75,19 +75,19 @@ describe GoCardlessPro::Services::MandatesService do
|
|
75
75
|
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
|
76
76
|
|
77
77
|
it 'retries timeouts' do
|
78
|
-
stub = stub_request(:post, %r{.*api.gocardless.com/mandates})
|
79
|
-
|
78
|
+
stub = stub_request(:post, %r{.*api.gocardless.com/mandates}).
|
79
|
+
to_timeout.then.to_return(status: 200, headers: response_headers)
|
80
80
|
|
81
81
|
post_create_response
|
82
82
|
expect(stub).to have_been_requested.twice
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'retries 5XX errors' do
|
86
|
-
stub = stub_request(:post, %r{.*api.gocardless.com/mandates})
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
86
|
+
stub = stub_request(:post, %r{.*api.gocardless.com/mandates}).
|
87
|
+
to_return(status: 502,
|
88
|
+
headers: { 'Content-Type' => 'text/html' },
|
89
|
+
body: '<html><body>Response from Cloudflare</body></html>').
|
90
|
+
then.to_return(status: 200, headers: response_headers)
|
91
91
|
|
92
92
|
post_create_response
|
93
93
|
expect(stub).to have_been_requested.twice
|
@@ -105,9 +105,9 @@ describe GoCardlessPro::Services::MandatesService do
|
|
105
105
|
type: 'validation_failed',
|
106
106
|
code: 422,
|
107
107
|
errors: [
|
108
|
-
{ message: 'test error message', field: 'test_field' }
|
109
|
-
]
|
110
|
-
}
|
108
|
+
{ message: 'test error message', field: 'test_field' },
|
109
|
+
],
|
110
|
+
},
|
111
111
|
}.to_json,
|
112
112
|
headers: response_headers,
|
113
113
|
status: 422
|
@@ -133,7 +133,7 @@ describe GoCardlessPro::Services::MandatesService do
|
|
133
133
|
'payments_require_approval' => 'payments_require_approval-input',
|
134
134
|
'reference' => 'reference-input',
|
135
135
|
'scheme' => 'scheme-input',
|
136
|
-
'status' => 'status-input'
|
136
|
+
'status' => 'status-input',
|
137
137
|
}
|
138
138
|
end
|
139
139
|
|
@@ -148,11 +148,11 @@ describe GoCardlessPro::Services::MandatesService do
|
|
148
148
|
message: 'A resource has already been created with this idempotency key',
|
149
149
|
reason: 'idempotent_creation_conflict',
|
150
150
|
links: {
|
151
|
-
conflicting_resource_id: id
|
152
|
-
}
|
153
|
-
}
|
154
|
-
]
|
155
|
-
}
|
151
|
+
conflicting_resource_id: id,
|
152
|
+
},
|
153
|
+
},
|
154
|
+
],
|
155
|
+
},
|
156
156
|
}.to_json,
|
157
157
|
headers: response_headers,
|
158
158
|
status: 409
|
@@ -161,8 +161,8 @@ describe GoCardlessPro::Services::MandatesService do
|
|
161
161
|
|
162
162
|
let!(:get_stub) do
|
163
163
|
stub_url = "/mandates/#{id}"
|
164
|
-
stub_request(:get, /.*api.gocardless.com#{stub_url}/)
|
165
|
-
|
164
|
+
stub_request(:get, /.*api.gocardless.com#{stub_url}/).
|
165
|
+
to_return(
|
166
166
|
body: {
|
167
167
|
'mandates' => {
|
168
168
|
|
@@ -174,8 +174,8 @@ describe GoCardlessPro::Services::MandatesService do
|
|
174
174
|
'payments_require_approval' => 'payments_require_approval-input',
|
175
175
|
'reference' => 'reference-input',
|
176
176
|
'scheme' => 'scheme-input',
|
177
|
-
'status' => 'status-input'
|
178
|
-
}
|
177
|
+
'status' => 'status-input',
|
178
|
+
},
|
179
179
|
}.to_json,
|
180
180
|
headers: response_headers
|
181
181
|
)
|
@@ -205,14 +205,14 @@ describe GoCardlessPro::Services::MandatesService do
|
|
205
205
|
'payments_require_approval' => 'payments_require_approval-input',
|
206
206
|
'reference' => 'reference-input',
|
207
207
|
'scheme' => 'scheme-input',
|
208
|
-
'status' => 'status-input'
|
208
|
+
'status' => 'status-input',
|
209
209
|
}],
|
210
210
|
meta: {
|
211
211
|
cursors: {
|
212
212
|
before: nil,
|
213
|
-
after: 'ABC123'
|
214
|
-
}
|
215
|
-
}
|
213
|
+
after: 'ABC123',
|
214
|
+
},
|
215
|
+
},
|
216
216
|
}.to_json
|
217
217
|
end
|
218
218
|
|
@@ -254,19 +254,19 @@ describe GoCardlessPro::Services::MandatesService do
|
|
254
254
|
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
|
255
255
|
|
256
256
|
it 'retries timeouts' do
|
257
|
-
stub = stub_request(:get, %r{.*api.gocardless.com/mandates})
|
258
|
-
|
257
|
+
stub = stub_request(:get, %r{.*api.gocardless.com/mandates}).
|
258
|
+
to_timeout.then.to_return(status: 200, headers: response_headers, body: body)
|
259
259
|
|
260
260
|
get_list_response
|
261
261
|
expect(stub).to have_been_requested.twice
|
262
262
|
end
|
263
263
|
|
264
264
|
it 'retries 5XX errors' do
|
265
|
-
stub = stub_request(:get, %r{.*api.gocardless.com/mandates})
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
265
|
+
stub = stub_request(:get, %r{.*api.gocardless.com/mandates}).
|
266
|
+
to_return(status: 502,
|
267
|
+
headers: { 'Content-Type' => 'text/html' },
|
268
|
+
body: '<html><body>Response from Cloudflare</body></html>').
|
269
|
+
then.to_return(status: 200, headers: response_headers, body: body)
|
270
270
|
|
271
271
|
get_list_response
|
272
272
|
expect(stub).to have_been_requested.twice
|
@@ -289,12 +289,12 @@ describe GoCardlessPro::Services::MandatesService do
|
|
289
289
|
'payments_require_approval' => 'payments_require_approval-input',
|
290
290
|
'reference' => 'reference-input',
|
291
291
|
'scheme' => 'scheme-input',
|
292
|
-
'status' => 'status-input'
|
292
|
+
'status' => 'status-input',
|
293
293
|
}],
|
294
294
|
meta: {
|
295
295
|
cursors: { after: 'AB345' },
|
296
|
-
limit: 1
|
297
|
-
}
|
296
|
+
limit: 1,
|
297
|
+
},
|
298
298
|
}.to_json,
|
299
299
|
headers: response_headers
|
300
300
|
)
|
@@ -313,12 +313,12 @@ describe GoCardlessPro::Services::MandatesService do
|
|
313
313
|
'payments_require_approval' => 'payments_require_approval-input',
|
314
314
|
'reference' => 'reference-input',
|
315
315
|
'scheme' => 'scheme-input',
|
316
|
-
'status' => 'status-input'
|
316
|
+
'status' => 'status-input',
|
317
317
|
}],
|
318
318
|
meta: {
|
319
319
|
limit: 2,
|
320
|
-
cursors: {}
|
321
|
-
}
|
320
|
+
cursors: {},
|
321
|
+
},
|
322
322
|
}.to_json,
|
323
323
|
headers: response_headers
|
324
324
|
)
|
@@ -346,19 +346,19 @@ describe GoCardlessPro::Services::MandatesService do
|
|
346
346
|
'payments_require_approval' => 'payments_require_approval-input',
|
347
347
|
'reference' => 'reference-input',
|
348
348
|
'scheme' => 'scheme-input',
|
349
|
-
'status' => 'status-input'
|
349
|
+
'status' => 'status-input',
|
350
350
|
}],
|
351
351
|
meta: {
|
352
352
|
cursors: { after: 'AB345' },
|
353
|
-
limit: 1
|
354
|
-
}
|
353
|
+
limit: 1,
|
354
|
+
},
|
355
355
|
}.to_json,
|
356
356
|
headers: response_headers
|
357
357
|
)
|
358
358
|
|
359
|
-
second_response_stub = stub_request(:get, %r{.*api.gocardless.com/mandates\?after=AB345})
|
360
|
-
|
361
|
-
|
359
|
+
second_response_stub = stub_request(:get, %r{.*api.gocardless.com/mandates\?after=AB345}).
|
360
|
+
to_timeout.then.
|
361
|
+
to_return(
|
362
362
|
body: {
|
363
363
|
'mandates' => [{
|
364
364
|
|
@@ -370,12 +370,12 @@ describe GoCardlessPro::Services::MandatesService do
|
|
370
370
|
'payments_require_approval' => 'payments_require_approval-input',
|
371
371
|
'reference' => 'reference-input',
|
372
372
|
'scheme' => 'scheme-input',
|
373
|
-
'status' => 'status-input'
|
373
|
+
'status' => 'status-input',
|
374
374
|
}],
|
375
375
|
meta: {
|
376
376
|
limit: 2,
|
377
|
-
cursors: {}
|
378
|
-
}
|
377
|
+
cursors: {},
|
378
|
+
},
|
379
379
|
}.to_json,
|
380
380
|
headers: response_headers
|
381
381
|
)
|
@@ -399,18 +399,18 @@ describe GoCardlessPro::Services::MandatesService do
|
|
399
399
|
'payments_require_approval' => 'payments_require_approval-input',
|
400
400
|
'reference' => 'reference-input',
|
401
401
|
'scheme' => 'scheme-input',
|
402
|
-
'status' => 'status-input'
|
402
|
+
'status' => 'status-input',
|
403
403
|
}],
|
404
404
|
meta: {
|
405
405
|
cursors: { after: 'AB345' },
|
406
|
-
limit: 1
|
407
|
-
}
|
406
|
+
limit: 1,
|
407
|
+
},
|
408
408
|
}.to_json,
|
409
409
|
headers: response_headers
|
410
410
|
)
|
411
411
|
|
412
|
-
second_response_stub = stub_request(:get, %r{.*api.gocardless.com/mandates\?after=AB345})
|
413
|
-
|
412
|
+
second_response_stub = stub_request(:get, %r{.*api.gocardless.com/mandates\?after=AB345}).
|
413
|
+
to_return(
|
414
414
|
status: 502,
|
415
415
|
body: '<html><body>Response from Cloudflare</body></html>',
|
416
416
|
headers: { 'Content-Type' => 'text/html' }
|
@@ -426,12 +426,12 @@ describe GoCardlessPro::Services::MandatesService do
|
|
426
426
|
'payments_require_approval' => 'payments_require_approval-input',
|
427
427
|
'reference' => 'reference-input',
|
428
428
|
'scheme' => 'scheme-input',
|
429
|
-
'status' => 'status-input'
|
429
|
+
'status' => 'status-input',
|
430
430
|
}],
|
431
431
|
meta: {
|
432
432
|
limit: 2,
|
433
|
-
cursors: {}
|
434
|
-
}
|
433
|
+
cursors: {},
|
434
|
+
},
|
435
435
|
}.to_json,
|
436
436
|
headers: response_headers
|
437
437
|
)
|
@@ -452,9 +452,9 @@ describe GoCardlessPro::Services::MandatesService do
|
|
452
452
|
context 'passing in a custom header' do
|
453
453
|
let!(:stub) do
|
454
454
|
stub_url = '/mandates/:identity'.gsub(':identity', id)
|
455
|
-
stub_request(:get, /.*api.gocardless.com#{stub_url}/)
|
456
|
-
|
457
|
-
|
455
|
+
stub_request(:get, /.*api.gocardless.com#{stub_url}/).
|
456
|
+
with(headers: { 'Foo' => 'Bar' }).
|
457
|
+
to_return(
|
458
458
|
body: {
|
459
459
|
'mandates' => {
|
460
460
|
|
@@ -466,8 +466,8 @@ describe GoCardlessPro::Services::MandatesService do
|
|
466
466
|
'payments_require_approval' => 'payments_require_approval-input',
|
467
467
|
'reference' => 'reference-input',
|
468
468
|
'scheme' => 'scheme-input',
|
469
|
-
'status' => 'status-input'
|
470
|
-
}
|
469
|
+
'status' => 'status-input',
|
470
|
+
},
|
471
471
|
}.to_json,
|
472
472
|
headers: response_headers
|
473
473
|
)
|
@@ -475,7 +475,7 @@ describe GoCardlessPro::Services::MandatesService do
|
|
475
475
|
|
476
476
|
subject(:get_response) do
|
477
477
|
client.mandates.get(id, headers: {
|
478
|
-
'Foo' => 'Bar'
|
478
|
+
'Foo' => 'Bar',
|
479
479
|
})
|
480
480
|
end
|
481
481
|
|
@@ -500,8 +500,8 @@ describe GoCardlessPro::Services::MandatesService do
|
|
500
500
|
'payments_require_approval' => 'payments_require_approval-input',
|
501
501
|
'reference' => 'reference-input',
|
502
502
|
'scheme' => 'scheme-input',
|
503
|
-
'status' => 'status-input'
|
504
|
-
}
|
503
|
+
'status' => 'status-input',
|
504
|
+
},
|
505
505
|
}.to_json,
|
506
506
|
headers: response_headers
|
507
507
|
)
|
@@ -540,8 +540,8 @@ describe GoCardlessPro::Services::MandatesService do
|
|
540
540
|
it 'retries timeouts' do
|
541
541
|
stub_url = '/mandates/:identity'.gsub(':identity', id)
|
542
542
|
|
543
|
-
stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
|
544
|
-
|
543
|
+
stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
|
544
|
+
to_timeout.then.to_return(status: 200, headers: response_headers)
|
545
545
|
|
546
546
|
get_response
|
547
547
|
expect(stub).to have_been_requested.twice
|
@@ -550,11 +550,11 @@ describe GoCardlessPro::Services::MandatesService do
|
|
550
550
|
it 'retries 5XX errors' do
|
551
551
|
stub_url = '/mandates/:identity'.gsub(':identity', id)
|
552
552
|
|
553
|
-
stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
553
|
+
stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
|
554
|
+
to_return(status: 502,
|
555
|
+
headers: { 'Content-Type' => 'text/html' },
|
556
|
+
body: '<html><body>Response from Cloudflare</body></html>').
|
557
|
+
then.to_return(status: 200, headers: response_headers)
|
558
558
|
|
559
559
|
get_response
|
560
560
|
expect(stub).to have_been_requested.twice
|
@@ -583,8 +583,8 @@ describe GoCardlessPro::Services::MandatesService do
|
|
583
583
|
'payments_require_approval' => 'payments_require_approval-input',
|
584
584
|
'reference' => 'reference-input',
|
585
585
|
'scheme' => 'scheme-input',
|
586
|
-
'status' => 'status-input'
|
587
|
-
}
|
586
|
+
'status' => 'status-input',
|
587
|
+
},
|
588
588
|
}.to_json,
|
589
589
|
headers: response_headers
|
590
590
|
)
|
@@ -600,8 +600,8 @@ describe GoCardlessPro::Services::MandatesService do
|
|
600
600
|
|
601
601
|
it 'retries timeouts' do
|
602
602
|
stub_url = '/mandates/:identity'.gsub(':identity', id)
|
603
|
-
stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
|
604
|
-
|
603
|
+
stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
|
604
|
+
to_timeout.then.to_return(status: 200, headers: response_headers)
|
605
605
|
|
606
606
|
put_update_response
|
607
607
|
expect(stub).to have_been_requested.twice
|
@@ -609,11 +609,11 @@ describe GoCardlessPro::Services::MandatesService do
|
|
609
609
|
|
610
610
|
it 'retries 5XX errors' do
|
611
611
|
stub_url = '/mandates/:identity'.gsub(':identity', id)
|
612
|
-
stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
612
|
+
stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
|
613
|
+
to_return(status: 502,
|
614
|
+
headers: { 'Content-Type' => 'text/html' },
|
615
|
+
body: '<html><body>Response from Cloudflare</body></html>').
|
616
|
+
then.to_return(status: 200, headers: response_headers)
|
617
617
|
|
618
618
|
put_update_response
|
619
619
|
expect(stub).to have_been_requested.twice
|
@@ -642,8 +642,8 @@ describe GoCardlessPro::Services::MandatesService do
|
|
642
642
|
'payments_require_approval' => 'payments_require_approval-input',
|
643
643
|
'reference' => 'reference-input',
|
644
644
|
'scheme' => 'scheme-input',
|
645
|
-
'status' => 'status-input'
|
646
|
-
}
|
645
|
+
'status' => 'status-input',
|
646
|
+
},
|
647
647
|
}.to_json,
|
648
648
|
headers: response_headers
|
649
649
|
)
|
@@ -658,8 +658,8 @@ describe GoCardlessPro::Services::MandatesService do
|
|
658
658
|
describe 'retry behaviour' do
|
659
659
|
it "doesn't retry errors" do
|
660
660
|
stub_url = '/mandates/:identity/actions/cancel'.gsub(':identity', resource_id)
|
661
|
-
stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
|
662
|
-
|
661
|
+
stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
662
|
+
to_timeout
|
663
663
|
|
664
664
|
expect { post_response }.to raise_error(Faraday::TimeoutError)
|
665
665
|
expect(stub).to have_been_requested
|
@@ -676,8 +676,8 @@ describe GoCardlessPro::Services::MandatesService do
|
|
676
676
|
let!(:stub) do
|
677
677
|
# /mandates/%v/actions/cancel
|
678
678
|
stub_url = '/mandates/:identity/actions/cancel'.gsub(':identity', resource_id)
|
679
|
-
stub_request(:post, /.*api.gocardless.com#{stub_url}/)
|
680
|
-
|
679
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
680
|
+
with(
|
681
681
|
body: { foo: 'bar' },
|
682
682
|
headers: { 'Foo' => 'Bar' }
|
683
683
|
).to_return(
|
@@ -692,8 +692,8 @@ describe GoCardlessPro::Services::MandatesService do
|
|
692
692
|
'payments_require_approval' => 'payments_require_approval-input',
|
693
693
|
'reference' => 'reference-input',
|
694
694
|
'scheme' => 'scheme-input',
|
695
|
-
'status' => 'status-input'
|
696
|
-
}
|
695
|
+
'status' => 'status-input',
|
696
|
+
},
|
697
697
|
}.to_json,
|
698
698
|
headers: response_headers
|
699
699
|
)
|
@@ -721,8 +721,8 @@ describe GoCardlessPro::Services::MandatesService do
|
|
721
721
|
'payments_require_approval' => 'payments_require_approval-input',
|
722
722
|
'reference' => 'reference-input',
|
723
723
|
'scheme' => 'scheme-input',
|
724
|
-
'status' => 'status-input'
|
725
|
-
}
|
724
|
+
'status' => 'status-input',
|
725
|
+
},
|
726
726
|
}.to_json,
|
727
727
|
headers: response_headers
|
728
728
|
)
|
@@ -737,8 +737,8 @@ describe GoCardlessPro::Services::MandatesService do
|
|
737
737
|
describe 'retry behaviour' do
|
738
738
|
it "doesn't retry errors" do
|
739
739
|
stub_url = '/mandates/:identity/actions/reinstate'.gsub(':identity', resource_id)
|
740
|
-
stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
|
741
|
-
|
740
|
+
stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
741
|
+
to_timeout
|
742
742
|
|
743
743
|
expect { post_response }.to raise_error(Faraday::TimeoutError)
|
744
744
|
expect(stub).to have_been_requested
|
@@ -755,8 +755,8 @@ describe GoCardlessPro::Services::MandatesService do
|
|
755
755
|
let!(:stub) do
|
756
756
|
# /mandates/%v/actions/reinstate
|
757
757
|
stub_url = '/mandates/:identity/actions/reinstate'.gsub(':identity', resource_id)
|
758
|
-
stub_request(:post, /.*api.gocardless.com#{stub_url}/)
|
759
|
-
|
758
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
759
|
+
with(
|
760
760
|
body: { foo: 'bar' },
|
761
761
|
headers: { 'Foo' => 'Bar' }
|
762
762
|
).to_return(
|
@@ -771,8 +771,8 @@ describe GoCardlessPro::Services::MandatesService do
|
|
771
771
|
'payments_require_approval' => 'payments_require_approval-input',
|
772
772
|
'reference' => 'reference-input',
|
773
773
|
'scheme' => 'scheme-input',
|
774
|
-
'status' => 'status-input'
|
775
|
-
}
|
774
|
+
'status' => 'status-input',
|
775
|
+
},
|
776
776
|
}.to_json,
|
777
777
|
headers: response_headers
|
778
778
|
)
|