Skip to content

Commit 9cf9e64

Browse files
committed
[ING-30] test: Cover currency filter on lists
The lago-api backend exposes a `currency` query parameter on the subscriptions, wallets, and payment_requests list endpoints (PR #5249). The Ruby client forwards arbitrary options as query params via get_all, so no source change is needed, but the behavior was untested. Add a forwarding spec for the `currency` option to the get_all examples of the subscription, wallet, and payment_request resources. Each stubs the request with the currency query string, so the test fails if the option is not forwarded.
1 parent 791e306 commit 9cf9e64

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

spec/lago/api/resources/payment_request_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,20 @@
112112
end
113113
end
114114

115+
context 'when currency is given' do
116+
before do
117+
stub_request(:get, 'https://api.getlago.com/api/v1/payment_requests?currency=EUR')
118+
.to_return(body: payment_requests_response, status: 200)
119+
end
120+
121+
it 'returns payment requests filtered by currency' do
122+
response = resource.get_all({ currency: 'EUR' })
123+
124+
expect(response['payment_requests'].first['lago_id']).to eq(payment_request_id)
125+
expect(response['meta']['current_page']).to eq(1)
126+
end
127+
end
128+
115129
context 'when there is an issue' do
116130
before do
117131
stub_request(:get, 'https://api.getlago.com/api/v1/payment_requests')

spec/lago/api/resources/subscription_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,20 @@
451451
end
452452
end
453453

454+
context 'when currency is given' do
455+
before do
456+
stub_request(:get, 'https://api.getlago.com/api/v1/subscriptions?currency=EUR')
457+
.to_return(body: response, status: 200)
458+
end
459+
460+
it 'returns subscriptions filtered by currency' do
461+
response = resource.get_all({ currency: 'EUR' })
462+
463+
expect(response['subscriptions'].first['lago_id']).to eq(factory_subscription.lago_id)
464+
expect(response['meta']['current_page']).to eq(1)
465+
end
466+
end
467+
454468
context 'when status is given' do
455469
before do
456470
stub_request(:get, 'https://api.getlago.com/api/v1/subscriptions?external_customer_id=123&status%5B%5D=pending')

spec/lago/api/resources/wallet_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,20 @@
727727
end
728728
end
729729

730+
context 'when currency is given' do
731+
before do
732+
stub_request(:get, 'https://api.getlago.com/api/v1/wallets?currency=EUR')
733+
.to_return(body: response, status: 200)
734+
end
735+
736+
it 'returns wallets filtered by currency' do
737+
response = resource.get_all({ currency: 'EUR' })
738+
739+
expect(response['wallets'].first['lago_id']).to eq('this-is-lago-id')
740+
expect(response['meta']['current_page']).to eq(1)
741+
end
742+
end
743+
730744
context 'when there is an issue' do
731745
before do
732746
stub_request(:get, 'https://api.getlago.com/api/v1/wallets')

0 commit comments

Comments
 (0)