gocardless_pro 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -4
  3. data/lib/gocardless_pro.rb +1 -0
  4. data/lib/gocardless_pro/api_service.rb +2 -0
  5. data/lib/gocardless_pro/client.rb +4 -3
  6. data/lib/gocardless_pro/error/invalid_state_error.rb +17 -0
  7. data/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb +50 -0
  8. data/lib/gocardless_pro/request.rb +38 -1
  9. data/lib/gocardless_pro/resources/creditor.rb +2 -2
  10. data/lib/gocardless_pro/resources/creditor_bank_account.rb +11 -11
  11. data/lib/gocardless_pro/resources/customer_bank_account.rb +2 -2
  12. data/lib/gocardless_pro/resources/event.rb +2 -2
  13. data/lib/gocardless_pro/resources/mandate.rb +2 -2
  14. data/lib/gocardless_pro/resources/payment.rb +7 -7
  15. data/lib/gocardless_pro/resources/payout.rb +7 -6
  16. data/lib/gocardless_pro/resources/redirect_flow.rb +2 -2
  17. data/lib/gocardless_pro/resources/refund.rb +2 -2
  18. data/lib/gocardless_pro/resources/subscription.rb +2 -2
  19. data/lib/gocardless_pro/response.rb +2 -54
  20. data/lib/gocardless_pro/services/bank_details_lookups_service.rb +3 -0
  21. data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +31 -2
  22. data/lib/gocardless_pro/services/creditors_service.rb +21 -1
  23. data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +34 -2
  24. data/lib/gocardless_pro/services/customers_service.rb +21 -1
  25. data/lib/gocardless_pro/services/events_service.rb +5 -0
  26. data/lib/gocardless_pro/services/mandate_pdfs_service.rb +3 -0
  27. data/lib/gocardless_pro/services/mandates_service.rb +47 -3
  28. data/lib/gocardless_pro/services/payments_service.rb +47 -3
  29. data/lib/gocardless_pro/services/payouts_service.rb +5 -0
  30. data/lib/gocardless_pro/services/redirect_flows_service.rb +28 -2
  31. data/lib/gocardless_pro/services/refunds_service.rb +21 -1
  32. data/lib/gocardless_pro/services/subscriptions_service.rb +34 -2
  33. data/lib/gocardless_pro/version.rb +1 -1
  34. data/spec/api_service_spec.rb +106 -0
  35. data/spec/middlewares/raise_gocardless_errors_spec.rb +98 -0
  36. data/spec/resources/bank_details_lookup_spec.rb +102 -19
  37. data/spec/resources/creditor_bank_account_spec.rb +416 -40
  38. data/spec/resources/creditor_spec.rb +414 -53
  39. data/spec/resources/customer_bank_account_spec.rb +452 -40
  40. data/spec/resources/customer_spec.rb +457 -45
  41. data/spec/resources/event_spec.rb +171 -72
  42. data/spec/resources/mandate_pdf_spec.rb +100 -17
  43. data/spec/resources/mandate_spec.rb +501 -44
  44. data/spec/resources/payment_spec.rb +531 -48
  45. data/spec/resources/payout_spec.rb +189 -45
  46. data/spec/resources/redirect_flow_spec.rb +277 -43
  47. data/spec/resources/refund_spec.rb +349 -34
  48. data/spec/resources/subscription_spec.rb +531 -53
  49. data/spec/response_spec.rb +12 -79
  50. data/spec/services/bank_details_lookups_service_spec.rb +67 -2
  51. data/spec/services/creditor_bank_accounts_service_spec.rb +309 -31
  52. data/spec/services/creditors_service_spec.rb +343 -33
  53. data/spec/services/customer_bank_accounts_service_spec.rb +335 -32
  54. data/spec/services/customers_service_spec.rb +364 -36
  55. data/spec/services/events_service_spec.rb +185 -24
  56. data/spec/services/mandate_pdfs_service_spec.rb +66 -2
  57. data/spec/services/mandates_service_spec.rb +341 -33
  58. data/spec/services/payments_service_spec.rb +355 -35
  59. data/spec/services/payouts_service_spec.rb +206 -26
  60. data/spec/services/redirect_flows_service_spec.rb +137 -7
  61. data/spec/services/refunds_service_spec.rb +301 -27
  62. data/spec/services/subscriptions_service_spec.rb +377 -38
  63. metadata +6 -3
@@ -7,33 +7,40 @@ describe GoCardlessPro::Services::PayoutsService do
7
7
  )
8
8
  end
9
9
 
10
+ let(:response_headers) { { 'Content-Type' => 'application/json' } }
11
+
10
12
  describe '#list' do
11
13
  describe 'with no filters' do
12
14
  subject(:get_list_response) { client.payouts.list }
13
15
 
14
- before do
15
- stub_request(:get, %r{.*api.gocardless.com/payouts}).to_return(
16
- body: {
17
- 'payouts' => [{
16
+ let(:body) do
17
+ {
18
+ 'payouts' => [{
18
19
 
19
- 'amount' => 'amount-input',
20
- 'arrival_date' => 'arrival_date-input',
21
- 'created_at' => 'created_at-input',
22
- 'currency' => 'currency-input',
23
- 'deducted_fees' => 'deducted_fees-input',
24
- 'id' => 'id-input',
25
- 'links' => 'links-input',
26
- 'reference' => 'reference-input',
27
- 'status' => 'status-input'
28
- }],
29
- meta: {
30
- cursors: {
31
- before: nil,
32
- after: 'ABC123'
33
- }
20
+ 'amount' => 'amount-input',
21
+ 'arrival_date' => 'arrival_date-input',
22
+ 'created_at' => 'created_at-input',
23
+ 'currency' => 'currency-input',
24
+ 'deducted_fees' => 'deducted_fees-input',
25
+ 'id' => 'id-input',
26
+ 'links' => 'links-input',
27
+ 'payout_type' => 'payout_type-input',
28
+ 'reference' => 'reference-input',
29
+ 'status' => 'status-input'
30
+ }],
31
+ meta: {
32
+ cursors: {
33
+ before: nil,
34
+ after: 'ABC123'
34
35
  }
35
- }.to_json,
36
- headers: { 'Content-Type' => 'application/json' }
36
+ }
37
+ }.to_json
38
+ end
39
+
40
+ before do
41
+ stub_request(:get, %r{.*api.gocardless.com/payouts}).to_return(
42
+ body: body,
43
+ headers: response_headers
37
44
  )
38
45
  end
39
46
 
@@ -52,6 +59,8 @@ describe GoCardlessPro::Services::PayoutsService do
52
59
 
53
60
  expect(get_list_response.records.first.id).to eq('id-input')
54
61
 
62
+ expect(get_list_response.records.first.payout_type).to eq('payout_type-input')
63
+
55
64
  expect(get_list_response.records.first.reference).to eq('reference-input')
56
65
 
57
66
  expect(get_list_response.records.first.status).to eq('status-input')
@@ -63,6 +72,29 @@ describe GoCardlessPro::Services::PayoutsService do
63
72
  end
64
73
 
65
74
  specify { expect(get_list_response.api_response.headers).to eql('content-type' => 'application/json') }
75
+
76
+ describe 'retry behaviour' do
77
+ before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
78
+
79
+ it 'retries timeouts' do
80
+ stub = stub_request(:get, %r{.*api.gocardless.com/payouts})
81
+ .to_timeout.then.to_return(status: 200, headers: response_headers, body: body)
82
+
83
+ get_list_response
84
+ expect(stub).to have_been_requested.twice
85
+ end
86
+
87
+ it 'retries 5XX errors' do
88
+ stub = stub_request(:get, %r{.*api.gocardless.com/payouts})
89
+ .to_return(status: 502,
90
+ headers: { 'Content-Type' => 'text/html' },
91
+ body: '<html><body>Response from Cloudflare</body></html>')
92
+ .then.to_return(status: 200, headers: response_headers, body: body)
93
+
94
+ get_list_response
95
+ expect(stub).to have_been_requested.twice
96
+ end
97
+ end
66
98
  end
67
99
  end
68
100
 
@@ -79,6 +111,7 @@ describe GoCardlessPro::Services::PayoutsService do
79
111
  'deducted_fees' => 'deducted_fees-input',
80
112
  'id' => 'id-input',
81
113
  'links' => 'links-input',
114
+ 'payout_type' => 'payout_type-input',
82
115
  'reference' => 'reference-input',
83
116
  'status' => 'status-input'
84
117
  }],
@@ -87,7 +120,7 @@ describe GoCardlessPro::Services::PayoutsService do
87
120
  limit: 1
88
121
  }
89
122
  }.to_json,
90
- headers: { 'Content-Type' => 'application/json' }
123
+ headers: response_headers
91
124
  )
92
125
  end
93
126
 
@@ -103,6 +136,7 @@ describe GoCardlessPro::Services::PayoutsService do
103
136
  'deducted_fees' => 'deducted_fees-input',
104
137
  'id' => 'id-input',
105
138
  'links' => 'links-input',
139
+ 'payout_type' => 'payout_type-input',
106
140
  'reference' => 'reference-input',
107
141
  'status' => 'status-input'
108
142
  }],
@@ -111,7 +145,7 @@ describe GoCardlessPro::Services::PayoutsService do
111
145
  cursors: {}
112
146
  }
113
147
  }.to_json,
114
- headers: { 'Content-Type' => 'application/json' }
148
+ headers: response_headers
115
149
  )
116
150
  end
117
151
 
@@ -120,6 +154,123 @@ describe GoCardlessPro::Services::PayoutsService do
120
154
  expect(first_response_stub).to have_been_requested
121
155
  expect(second_response_stub).to have_been_requested
122
156
  end
157
+
158
+ describe 'retry behaviour' do
159
+ before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
160
+
161
+ it 'retries timeouts' do
162
+ first_response_stub = stub_request(:get, %r{.*api.gocardless.com/payouts$}).to_return(
163
+ body: {
164
+ 'payouts' => [{
165
+
166
+ 'amount' => 'amount-input',
167
+ 'arrival_date' => 'arrival_date-input',
168
+ 'created_at' => 'created_at-input',
169
+ 'currency' => 'currency-input',
170
+ 'deducted_fees' => 'deducted_fees-input',
171
+ 'id' => 'id-input',
172
+ 'links' => 'links-input',
173
+ 'payout_type' => 'payout_type-input',
174
+ 'reference' => 'reference-input',
175
+ 'status' => 'status-input'
176
+ }],
177
+ meta: {
178
+ cursors: { after: 'AB345' },
179
+ limit: 1
180
+ }
181
+ }.to_json,
182
+ headers: response_headers
183
+ )
184
+
185
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/payouts\?after=AB345})
186
+ .to_timeout.then
187
+ .to_return(
188
+ body: {
189
+ 'payouts' => [{
190
+
191
+ 'amount' => 'amount-input',
192
+ 'arrival_date' => 'arrival_date-input',
193
+ 'created_at' => 'created_at-input',
194
+ 'currency' => 'currency-input',
195
+ 'deducted_fees' => 'deducted_fees-input',
196
+ 'id' => 'id-input',
197
+ 'links' => 'links-input',
198
+ 'payout_type' => 'payout_type-input',
199
+ 'reference' => 'reference-input',
200
+ 'status' => 'status-input'
201
+ }],
202
+ meta: {
203
+ limit: 2,
204
+ cursors: {}
205
+ }
206
+ }.to_json,
207
+ headers: response_headers
208
+ )
209
+
210
+ client.payouts.all.to_a
211
+
212
+ expect(first_response_stub).to have_been_requested
213
+ expect(second_response_stub).to have_been_requested.twice
214
+ end
215
+
216
+ it 'retries 5XX errors' do
217
+ first_response_stub = stub_request(:get, %r{.*api.gocardless.com/payouts$}).to_return(
218
+ body: {
219
+ 'payouts' => [{
220
+
221
+ 'amount' => 'amount-input',
222
+ 'arrival_date' => 'arrival_date-input',
223
+ 'created_at' => 'created_at-input',
224
+ 'currency' => 'currency-input',
225
+ 'deducted_fees' => 'deducted_fees-input',
226
+ 'id' => 'id-input',
227
+ 'links' => 'links-input',
228
+ 'payout_type' => 'payout_type-input',
229
+ 'reference' => 'reference-input',
230
+ 'status' => 'status-input'
231
+ }],
232
+ meta: {
233
+ cursors: { after: 'AB345' },
234
+ limit: 1
235
+ }
236
+ }.to_json,
237
+ headers: response_headers
238
+ )
239
+
240
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/payouts\?after=AB345})
241
+ .to_return(
242
+ status: 502,
243
+ body: '<html><body>Response from Cloudflare</body></html>',
244
+ headers: { 'Content-Type' => 'text/html' }
245
+ ).then.to_return(
246
+ body: {
247
+ 'payouts' => [{
248
+
249
+ 'amount' => 'amount-input',
250
+ 'arrival_date' => 'arrival_date-input',
251
+ 'created_at' => 'created_at-input',
252
+ 'currency' => 'currency-input',
253
+ 'deducted_fees' => 'deducted_fees-input',
254
+ 'id' => 'id-input',
255
+ 'links' => 'links-input',
256
+ 'payout_type' => 'payout_type-input',
257
+ 'reference' => 'reference-input',
258
+ 'status' => 'status-input'
259
+ }],
260
+ meta: {
261
+ limit: 2,
262
+ cursors: {}
263
+ }
264
+ }.to_json,
265
+ headers: response_headers
266
+ )
267
+
268
+ client.payouts.all.to_a
269
+
270
+ expect(first_response_stub).to have_been_requested
271
+ expect(second_response_stub).to have_been_requested.twice
272
+ end
273
+ end
123
274
  end
124
275
 
125
276
  describe '#get' do
@@ -143,11 +294,12 @@ describe GoCardlessPro::Services::PayoutsService do
143
294
  'deducted_fees' => 'deducted_fees-input',
144
295
  'id' => 'id-input',
145
296
  'links' => 'links-input',
297
+ 'payout_type' => 'payout_type-input',
146
298
  'reference' => 'reference-input',
147
299
  'status' => 'status-input'
148
300
  }
149
301
  }.to_json,
150
- headers: { 'Content-Type' => 'application/json' }
302
+ headers: response_headers
151
303
  )
152
304
  end
153
305
 
@@ -177,11 +329,12 @@ describe GoCardlessPro::Services::PayoutsService do
177
329
  'deducted_fees' => 'deducted_fees-input',
178
330
  'id' => 'id-input',
179
331
  'links' => 'links-input',
332
+ 'payout_type' => 'payout_type-input',
180
333
  'reference' => 'reference-input',
181
334
  'status' => 'status-input'
182
335
  }
183
336
  }.to_json,
184
- headers: { 'Content-Type' => 'application/json' }
337
+ headers: response_headers
185
338
  )
186
339
  end
187
340
 
@@ -195,7 +348,7 @@ describe GoCardlessPro::Services::PayoutsService do
195
348
  stub_url = '/payouts/:identity'.gsub(':identity', id)
196
349
  stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
197
350
  body: '',
198
- headers: { 'Content-Type' => 'application/json' }
351
+ headers: response_headers
199
352
  )
200
353
  end
201
354
 
@@ -211,5 +364,32 @@ describe GoCardlessPro::Services::PayoutsService do
211
364
  expect { get_response }.to_not raise_error(/bad URI/)
212
365
  end
213
366
  end
367
+
368
+ describe 'retry behaviour' do
369
+ before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
370
+
371
+ it 'retries timeouts' do
372
+ stub_url = '/payouts/:identity'.gsub(':identity', id)
373
+
374
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
375
+ .to_timeout.then.to_return(status: 200, headers: response_headers)
376
+
377
+ get_response
378
+ expect(stub).to have_been_requested.twice
379
+ end
380
+
381
+ it 'retries 5XX errors' do
382
+ stub_url = '/payouts/:identity'.gsub(':identity', id)
383
+
384
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
385
+ .to_return(status: 502,
386
+ headers: { 'Content-Type' => 'text/html' },
387
+ body: '<html><body>Response from Cloudflare</body></html>')
388
+ .then.to_return(status: 200, headers: response_headers)
389
+
390
+ get_response
391
+ expect(stub).to have_been_requested.twice
392
+ end
393
+ end
214
394
  end
215
395
  end
@@ -7,6 +7,8 @@ describe GoCardlessPro::Services::RedirectFlowsService do
7
7
  )
8
8
  end
9
9
 
10
+ let(:response_headers) { { 'Content-Type' => 'application/json' } }
11
+
10
12
  describe '#create' do
11
13
  subject(:post_create_response) { client.redirect_flows.create(params: new_resource) }
12
14
  context 'with a valid request' do
@@ -58,13 +60,36 @@ describe GoCardlessPro::Services::RedirectFlowsService do
58
60
  }
59
61
 
60
62
  }.to_json,
61
- headers: { 'Content-Type' => 'application/json' }
63
+ headers: response_headers
62
64
  )
63
65
  end
64
66
 
65
67
  it 'creates and returns the resource' do
66
68
  expect(post_create_response).to be_a(GoCardlessPro::Resources::RedirectFlow)
67
69
  end
70
+
71
+ describe 'retry behaviour' do
72
+ before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
73
+
74
+ it 'retries timeouts' do
75
+ stub = stub_request(:post, %r{.*api.gocardless.com/redirect_flows})
76
+ .to_timeout.then.to_return(status: 200, headers: response_headers)
77
+
78
+ post_create_response
79
+ expect(stub).to have_been_requested.twice
80
+ end
81
+
82
+ it 'retries 5XX errors' do
83
+ stub = stub_request(:post, %r{.*api.gocardless.com/redirect_flows})
84
+ .to_return(status: 502,
85
+ headers: { 'Content-Type' => 'text/html' },
86
+ body: '<html><body>Response from Cloudflare</body></html>')
87
+ .then.to_return(status: 200, headers: response_headers)
88
+
89
+ post_create_response
90
+ expect(stub).to have_been_requested.twice
91
+ end
92
+ end
68
93
  end
69
94
 
70
95
  context 'with a request that returns a validation error' do
@@ -81,7 +106,7 @@ describe GoCardlessPro::Services::RedirectFlowsService do
81
106
  ]
82
107
  }
83
108
  }.to_json,
84
- headers: { 'Content-Type' => 'application/json' },
109
+ headers: response_headers,
85
110
  status: 422
86
111
  )
87
112
  end
@@ -90,6 +115,73 @@ describe GoCardlessPro::Services::RedirectFlowsService do
90
115
  expect { post_create_response }.to raise_error(GoCardlessPro::ValidationError)
91
116
  end
92
117
  end
118
+
119
+ context 'with a request that returns an idempotent creation conflict error' do
120
+ let(:id) { 'ID123' }
121
+
122
+ let(:new_resource) do
123
+ {
124
+
125
+ 'created_at' => 'created_at-input',
126
+ 'description' => 'description-input',
127
+ 'id' => 'id-input',
128
+ 'links' => 'links-input',
129
+ 'redirect_url' => 'redirect_url-input',
130
+ 'scheme' => 'scheme-input',
131
+ 'session_token' => 'session_token-input',
132
+ 'success_redirect_url' => 'success_redirect_url-input'
133
+ }
134
+ end
135
+
136
+ let!(:post_stub) do
137
+ stub_request(:post, %r{.*api.gocardless.com/redirect_flows}).to_return(
138
+ body: {
139
+ error: {
140
+ type: 'invalid_state',
141
+ code: 409,
142
+ errors: [
143
+ {
144
+ message: 'A resource has already been created with this idempotency key',
145
+ reason: 'idempotent_creation_conflict',
146
+ links: {
147
+ conflicting_resource_id: id
148
+ }
149
+ }
150
+ ]
151
+ }
152
+ }.to_json,
153
+ headers: response_headers,
154
+ status: 409
155
+ )
156
+ end
157
+
158
+ let!(:get_stub) do
159
+ stub_url = "/redirect_flows/#{id}"
160
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/)
161
+ .to_return(
162
+ body: {
163
+ 'redirect_flows' => {
164
+
165
+ 'created_at' => 'created_at-input',
166
+ 'description' => 'description-input',
167
+ 'id' => 'id-input',
168
+ 'links' => 'links-input',
169
+ 'redirect_url' => 'redirect_url-input',
170
+ 'scheme' => 'scheme-input',
171
+ 'session_token' => 'session_token-input',
172
+ 'success_redirect_url' => 'success_redirect_url-input'
173
+ }
174
+ }.to_json,
175
+ headers: response_headers
176
+ )
177
+ end
178
+
179
+ it 'fetches the already-created resource' do
180
+ post_create_response
181
+ expect(post_stub).to have_been_requested
182
+ expect(get_stub).to have_been_requested
183
+ end
184
+ end
93
185
  end
94
186
 
95
187
  describe '#get' do
@@ -116,7 +208,7 @@ describe GoCardlessPro::Services::RedirectFlowsService do
116
208
  'success_redirect_url' => 'success_redirect_url-input'
117
209
  }
118
210
  }.to_json,
119
- headers: { 'Content-Type' => 'application/json' }
211
+ headers: response_headers
120
212
  )
121
213
  end
122
214
 
@@ -149,7 +241,7 @@ describe GoCardlessPro::Services::RedirectFlowsService do
149
241
  'success_redirect_url' => 'success_redirect_url-input'
150
242
  }
151
243
  }.to_json,
152
- headers: { 'Content-Type' => 'application/json' }
244
+ headers: response_headers
153
245
  )
154
246
  end
155
247
 
@@ -163,7 +255,7 @@ describe GoCardlessPro::Services::RedirectFlowsService do
163
255
  stub_url = '/redirect_flows/:identity'.gsub(':identity', id)
164
256
  stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
165
257
  body: '',
166
- headers: { 'Content-Type' => 'application/json' }
258
+ headers: response_headers
167
259
  )
168
260
  end
169
261
 
@@ -179,6 +271,33 @@ describe GoCardlessPro::Services::RedirectFlowsService do
179
271
  expect { get_response }.to_not raise_error(/bad URI/)
180
272
  end
181
273
  end
274
+
275
+ describe 'retry behaviour' do
276
+ before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
277
+
278
+ it 'retries timeouts' do
279
+ stub_url = '/redirect_flows/:identity'.gsub(':identity', id)
280
+
281
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
282
+ .to_timeout.then.to_return(status: 200, headers: response_headers)
283
+
284
+ get_response
285
+ expect(stub).to have_been_requested.twice
286
+ end
287
+
288
+ it 'retries 5XX errors' do
289
+ stub_url = '/redirect_flows/:identity'.gsub(':identity', id)
290
+
291
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
292
+ .to_return(status: 502,
293
+ headers: { 'Content-Type' => 'text/html' },
294
+ body: '<html><body>Response from Cloudflare</body></html>')
295
+ .then.to_return(status: 200, headers: response_headers)
296
+
297
+ get_response
298
+ expect(stub).to have_been_requested.twice
299
+ end
300
+ end
182
301
  end
183
302
 
184
303
  describe '#complete' do
@@ -203,7 +322,7 @@ describe GoCardlessPro::Services::RedirectFlowsService do
203
322
  'success_redirect_url' => 'success_redirect_url-input'
204
323
  }
205
324
  }.to_json,
206
- headers: { 'Content-Type' => 'application/json' }
325
+ headers: response_headers
207
326
  )
208
327
  end
209
328
 
@@ -213,6 +332,17 @@ describe GoCardlessPro::Services::RedirectFlowsService do
213
332
  expect(stub).to have_been_requested
214
333
  end
215
334
 
335
+ describe 'retry behaviour' do
336
+ it "doesn't retry errors" do
337
+ stub_url = '/redirect_flows/:identity/actions/complete'.gsub(':identity', resource_id)
338
+ stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
339
+ .to_timeout
340
+
341
+ expect { post_response }.to raise_error(Faraday::TimeoutError)
342
+ expect(stub).to have_been_requested
343
+ end
344
+ end
345
+
216
346
  context 'when the request needs a body and custom header' do
217
347
  let(:body) { { foo: 'bar' } }
218
348
  let(:headers) { { 'Foo' => 'Bar' } }
@@ -241,7 +371,7 @@ describe GoCardlessPro::Services::RedirectFlowsService do
241
371
  'success_redirect_url' => 'success_redirect_url-input'
242
372
  }
243
373
  }.to_json,
244
- headers: { 'Content-Type' => 'application/json' }
374
+ headers: response_headers
245
375
  )
246
376
  end
247
377
  end