Sha256: fb94aa7a1323594786cd3cd81baaff2dbc06bf807eae6b2626744ee388c54054
Contents?: true
Size: 1.37 KB
Versions: 47
Compression:
Stored size: 1.37 KB
Contents
describe MangoPay do # see https://docs.mangopay.com/api-references/idempotency-support/ include_context 'users' require 'securerandom' describe 'post requests' do it 'if called with no idempotency key, act independently' do u = define_new_natural_user u1 = MangoPay::NaturalUser.create(u) u2 = MangoPay::NaturalUser.create(u) expect(u2['Id']).to be > u1['Id'] end it 'if called with same idempotency key, the 2nd call is blocked' do idempotency_key = SecureRandom.uuid u = define_new_natural_user u1 = MangoPay::NaturalUser.create(u, nil, idempotency_key) expect { u2 = MangoPay::NaturalUser.create(u, nil, idempotency_key) }.to raise_error(MangoPay::ResponseError) end it 'if called with different idempotency key, act independently and responses may be retreived later' do idempotency_key1 = SecureRandom.uuid idempotency_key2 = SecureRandom.uuid u = define_new_natural_user u1 = MangoPay::NaturalUser.create(u, nil, idempotency_key1) u2 = MangoPay::NaturalUser.create(u, nil, idempotency_key2) expect(u2['Id']).to be > u1['Id'] resp1 = MangoPay.fetch_response(idempotency_key1) resp2 = MangoPay.fetch_response(idempotency_key2) expect(resp1['Resource']['Id']).to eq u1['Id'] expect(resp2['Resource']['Id']).to eq u2['Id'] end end end
Version data entries
47 entries across 47 versions & 1 rubygems