Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions spec/integration/customers/wallets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ def assert_wallet_attributes(wallet, **attributes)
end

def assert_wallet_attributes_with_updated_balance(wallet, **attributes)
# balance_cents is synced synchronously when the wallet transaction settles, but
# ongoing_balance_cents is refreshed by an async job (RefreshWalletJob), so re-fetch
# until the ongoing refresh has landed before asserting.
expected_ongoing_balance_cents = attributes.fetch(:ongoing_balance_cents, 2000)
wait_until do
wallet = client.customers.wallets.get(wallet.external_customer_id, wallet.code)
wallet.ongoing_balance_cents == expected_ongoing_balance_cents
end

assert_wallet_attributes(
wallet,
credits_balance: '10.0',
Expand Down
9 changes: 9 additions & 0 deletions spec/integration/wallets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ def assert_wallet_attributes(wallet, **attributes)
end

def assert_wallet_attributes_with_updated_balance(wallet, **attributes)
# balance_cents is synced synchronously when the wallet transaction settles, but
# ongoing_balance_cents is refreshed by an async job (RefreshWalletJob), so re-fetch
# until the ongoing refresh has landed before asserting.
expected_ongoing_balance_cents = attributes.fetch(:ongoing_balance_cents, 2000)
wait_until do
wallet = client.wallets.get(wallet.lago_id)
wallet.ongoing_balance_cents == expected_ongoing_balance_cents
end

assert_wallet_attributes(
wallet,
credits_balance: '10.0',
Expand Down
Loading