Replaces stubs for non-existing customer test case

This commit is contained in:
filipefurtad0
2024-01-31 19:05:38 +00:00
parent 57f55d7585
commit 949b515bfb
2 changed files with 105 additions and 16 deletions

View File

@@ -13,8 +13,6 @@ http_interactions:
- Bearer <HIDDEN-STRIPE_SECRET_TEST_API_KEY>
Content-Type:
- application/x-www-form-urlencoded
X-Stripe-Client-Telemetry:
- '{"last_request_metrics":{"request_id":"req_nVxOB6GyIQjq2r","request_duration_ms":846}}'
Stripe-Version:
- '2023-10-16'
X-Stripe-Client-User-Agent:
@@ -34,11 +32,11 @@ http_interactions:
Server:
- nginx
Date:
- Wed, 31 Jan 2024 18:56:27 GMT
- Wed, 31 Jan 2024 19:04:42 GMT
Content-Type:
- application/json
Content-Length:
- '930'
- '1084'
Connection:
- keep-alive
Access-Control-Allow-Credentials:
@@ -59,11 +57,11 @@ http_interactions:
default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none';
img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'
Idempotency-Key:
- b8b37c57-b454-4fb7-b611-cb1df87378a5
- 47d21ec0-d1bb-41dc-98de-94c985992cb1
Original-Request:
- req_gPgo73OOv0lXWh
- req_DzVgCjW9ZQ146O
Request-Id:
- req_gPgo73OOv0lXWh
- req_DzVgCjW9ZQ146O
Stripe-Should-Retry:
- 'false'
Stripe-Version:
@@ -78,7 +76,7 @@ http_interactions:
encoding: UTF-8
string: |-
{
"id": "pm_1OeixTKuuB1fWySnH9EJcJkx",
"id": "pm_1Oej5SKuuB1fWySnd7KqZATn",
"object": "payment_method",
"billing_details": {
"address": {
@@ -101,6 +99,11 @@ http_interactions:
"cvc_check": "unchecked"
},
"country": "US",
"display_brand": {
"label": "Visa",
"logo_url": "https://b.stripecdn.com/cards-metadata/logos/card-visa.svg",
"type": "visa"
},
"exp_month": 8,
"exp_year": 2025,
"fingerprint": "6E6tgVjx6U65iHFV",
@@ -118,11 +121,94 @@ http_interactions:
},
"wallet": null
},
"created": 1706727387,
"created": 1706727882,
"customer": null,
"livemode": false,
"metadata": {},
"type": "card"
}
recorded_at: Wed, 31 Jan 2024 18:56:27 GMT
recorded_at: Wed, 31 Jan 2024 19:04:42 GMT
- request:
method: get
uri: https://api.stripe.com/v1/customers/non_existing_customer_id
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- Stripe/v1 RubyBindings/10.6.0
Authorization:
- Bearer <HIDDEN-STRIPE_SECRET_TEST_API_KEY>
Content-Type:
- application/x-www-form-urlencoded
X-Stripe-Client-Telemetry:
- '{"last_request_metrics":{"request_id":"req_DzVgCjW9ZQ146O","request_duration_ms":719}}'
Stripe-Version:
- '2023-10-16'
X-Stripe-Client-User-Agent:
- '{"bindings_version":"10.6.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux
version 6.5.0-15-generic (buildd@bos03-amd64-040) (x86_64-linux-gnu-gcc-12
(Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38)
#15~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 12 18:54:30 UTC 2","hostname":"ff-LAT"}'
Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept:
- "*/*"
response:
status:
code: 404
message: Not Found
headers:
Server:
- nginx
Date:
- Wed, 31 Jan 2024 19:04:43 GMT
Content-Type:
- application/json
Content-Length:
- '339'
Connection:
- keep-alive
Access-Control-Allow-Credentials:
- 'true'
Access-Control-Allow-Methods:
- GET,HEAD,PUT,PATCH,POST,DELETE
Access-Control-Allow-Origin:
- "*"
Access-Control-Expose-Headers:
- Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,
X-Stripe-Privileged-Session-Required
Access-Control-Max-Age:
- '300'
Cache-Control:
- no-cache, no-store
Content-Security-Policy:
- report-uri https://q.stripe.com/csp-report?p=v1%2Fcustomers%2F%3Acustomer;
block-all-mixed-content; default-src 'none'; base-uri 'none'; form-action
'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample';
style-src 'self'
Request-Id:
- req_kfp8zfiuKDQeCw
Stripe-Version:
- '2023-10-16'
Vary:
- Origin
X-Stripe-Routing-Context-Priority-Tier:
- api-testmode
Strict-Transport-Security:
- max-age=63072000; includeSubDomains; preload
body:
encoding: UTF-8
string: |
{
"error": {
"code": "resource_missing",
"doc_url": "https://stripe.com/docs/error-codes/resource-missing",
"message": "No such customer: 'non_existing_customer_id'",
"param": "id",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_kfp8zfiuKDQeCw?t=1706727882",
"type": "invalid_request_error"
}
}
recorded_at: Wed, 31 Jan 2024 19:04:43 GMT
recorded_with: VCR 6.2.0

View File

@@ -89,13 +89,16 @@ describe Stripe::CreditCardRemover do
end
context 'Stripe customer does not exist' do
it 'deletes the credit card clone' do
allow(Stripe::Customer).to receive(:retrieve).and_return(nil)
let(:non_existing_customer_id) { 'non_existing_customer_id' }
expect_any_instance_of(Stripe::CreditCardCloneDestroyer).to receive(:destroy_clones).with(
credit_card
)
Stripe::CreditCardRemover.new(credit_card).call
before do
credit_card.update_attribute :gateway_customer_profile_id, non_existing_customer_id
end
it 'deletes the credit card clone' do
expect {
Stripe::CreditCardRemover.new(credit_card).call
}.to raise_error Stripe::InvalidRequestError
end
end
end