[ING-30] test: Cover currency filter on list endpoints#353
Open
aquinofb wants to merge 2 commits into
Open
Conversation
## 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.
mariohd
approved these changes
Jun 3, 2026
toommz
reviewed
Jun 3, 2026
Comment on lines
+99
to
+111
| 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 |
There was a problem hiding this comment.
As it returns the same results as the when there is no options context, I don't really see the added value of this example 🤔
## 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.
groyoh
requested changes
Jun 10, 2026
| it 'forwards the currency option as a query param' do | ||
| resource.get_all({ currency: 'EUR' }) | ||
|
|
||
| expect(WebMock).to have_requested(:get, 'https://api.getlago.com/api/v1/payment_requests') |
Contributor
There was a problem hiding this comment.
We shouldn't have to mock webmock since we're already stubbing. 🤔
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
The lago-api backend exposes an optional
currencyquery parameter on the subscriptions, wallets, and payment_requests list endpoints (getlago/lago-api#5249). The Ruby client'sget_all(options = {})already forwards arbitrary options as query parameters, so no source change is required, but the behavior was untested.Description
Adds a
when currency is givenexample to the#get_allspecs of the subscription, wallet, and payment_request resources. Each stubs the request with thecurrencyquery string, so the example fails (WebMock raises on an unmatched request) if the option is not forwarded.How to try locally