From 9ac2ac52669712219eef858bc970773d313a84f5 Mon Sep 17 00:00:00 2001 From: Felipe Rodrigues Date: Wed, 27 May 2026 12:02:28 -0300 Subject: [PATCH 1/2] [ING-30] test: Cover currency filter on lists ## Context 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. ## Description 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. --- spec/lago/api/resources/payment_request_spec.rb | 14 ++++++++++++++ spec/lago/api/resources/subscription_spec.rb | 14 ++++++++++++++ spec/lago/api/resources/wallet_spec.rb | 14 ++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/spec/lago/api/resources/payment_request_spec.rb b/spec/lago/api/resources/payment_request_spec.rb index 536a17ff..34fdf707 100644 --- a/spec/lago/api/resources/payment_request_spec.rb +++ b/spec/lago/api/resources/payment_request_spec.rb @@ -96,6 +96,20 @@ end end + context 'when currency is given' do + before do + stub_request(:get, 'https://api.getlago.com/api/v1/payment_requests?currency=EUR') + .to_return(body: payment_requests_response, status: 200) + end + + it 'returns payment requests filtered by currency' do + response = resource.get_all({ currency: 'EUR' }) + + expect(response['payment_requests'].first['lago_id']).to eq(payment_request_id) + expect(response['meta']['current_page']).to eq(1) + end + end + context 'when there is an issue' do before do stub_request(:get, 'https://api.getlago.com/api/v1/payment_requests') diff --git a/spec/lago/api/resources/subscription_spec.rb b/spec/lago/api/resources/subscription_spec.rb index 28cf5de7..51b843fc 100644 --- a/spec/lago/api/resources/subscription_spec.rb +++ b/spec/lago/api/resources/subscription_spec.rb @@ -417,6 +417,20 @@ end end + context 'when currency is given' do + before do + stub_request(:get, 'https://api.getlago.com/api/v1/subscriptions?currency=EUR') + .to_return(body: response, status: 200) + end + + it 'returns subscriptions filtered by currency' do + response = resource.get_all({ currency: 'EUR' }) + + expect(response['subscriptions'].first['lago_id']).to eq(factory_subscription.lago_id) + expect(response['meta']['current_page']).to eq(1) + end + end + context 'when status is given' do before do stub_request(:get, 'https://api.getlago.com/api/v1/subscriptions?external_customer_id=123&status%5B%5D=pending') diff --git a/spec/lago/api/resources/wallet_spec.rb b/spec/lago/api/resources/wallet_spec.rb index 734d4bd8..9b2d2170 100644 --- a/spec/lago/api/resources/wallet_spec.rb +++ b/spec/lago/api/resources/wallet_spec.rb @@ -675,6 +675,20 @@ end end + context 'when currency is given' do + before do + stub_request(:get, 'https://api.getlago.com/api/v1/wallets?currency=EUR') + .to_return(body: response, status: 200) + end + + it 'returns wallets filtered by currency' do + response = resource.get_all({ currency: 'EUR' }) + + expect(response['wallets'].first['lago_id']).to eq('this-is-lago-id') + expect(response['meta']['current_page']).to eq(1) + end + end + context 'when there is an issue' do before do stub_request(:get, 'https://api.getlago.com/api/v1/wallets') From 8a67933b2182f51009f6464256881be2b59f1299 Mon Sep 17 00:00:00 2001 From: Felipe Rodrigues Date: Mon, 8 Jun 2026 09:16:44 -0300 Subject: [PATCH 2/2] [ING-30] test: Assert the currency query param explicitly ## Context Review feedback on the currency-filter spec contexts: the stubbed URL matched on the query string, so the test failed if the param was not forwarded, but the assertions only checked the response shape. A future reader could not tell from the test what was being verified. ## Description Replace the response-shape assertions with an explicit `have_requested(...).with(query: { currency: 'EUR' })` on each of the three resources (payment_request, subscription, wallet). The intent of each test is now self-documenting: we are verifying the option is serialized into the request URL. --- spec/lago/api/resources/payment_request_spec.rb | 8 ++++---- spec/lago/api/resources/subscription_spec.rb | 8 ++++---- spec/lago/api/resources/wallet_spec.rb | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/spec/lago/api/resources/payment_request_spec.rb b/spec/lago/api/resources/payment_request_spec.rb index 34fdf707..9d6528b5 100644 --- a/spec/lago/api/resources/payment_request_spec.rb +++ b/spec/lago/api/resources/payment_request_spec.rb @@ -102,11 +102,11 @@ .to_return(body: payment_requests_response, status: 200) end - it 'returns payment requests filtered by currency' do - response = resource.get_all({ currency: 'EUR' }) + it 'forwards the currency option as a query param' do + resource.get_all({ currency: 'EUR' }) - expect(response['payment_requests'].first['lago_id']).to eq(payment_request_id) - expect(response['meta']['current_page']).to eq(1) + expect(WebMock).to have_requested(:get, 'https://api.getlago.com/api/v1/payment_requests') + .with(query: { currency: 'EUR' }) end end diff --git a/spec/lago/api/resources/subscription_spec.rb b/spec/lago/api/resources/subscription_spec.rb index 51b843fc..27e1b4c8 100644 --- a/spec/lago/api/resources/subscription_spec.rb +++ b/spec/lago/api/resources/subscription_spec.rb @@ -423,11 +423,11 @@ .to_return(body: response, status: 200) end - it 'returns subscriptions filtered by currency' do - response = resource.get_all({ currency: 'EUR' }) + it 'forwards the currency option as a query param' do + resource.get_all({ currency: 'EUR' }) - expect(response['subscriptions'].first['lago_id']).to eq(factory_subscription.lago_id) - expect(response['meta']['current_page']).to eq(1) + expect(WebMock).to have_requested(:get, 'https://api.getlago.com/api/v1/subscriptions') + .with(query: { currency: 'EUR' }) end end diff --git a/spec/lago/api/resources/wallet_spec.rb b/spec/lago/api/resources/wallet_spec.rb index 9b2d2170..9fcd4ceb 100644 --- a/spec/lago/api/resources/wallet_spec.rb +++ b/spec/lago/api/resources/wallet_spec.rb @@ -681,11 +681,11 @@ .to_return(body: response, status: 200) end - it 'returns wallets filtered by currency' do - response = resource.get_all({ currency: 'EUR' }) + it 'forwards the currency option as a query param' do + resource.get_all({ currency: 'EUR' }) - expect(response['wallets'].first['lago_id']).to eq('this-is-lago-id') - expect(response['meta']['current_page']).to eq(1) + expect(WebMock).to have_requested(:get, 'https://api.getlago.com/api/v1/wallets') + .with(query: { currency: 'EUR' }) end end