mirror of
https://github.com/internetee/registry.git
synced 2025-07-29 14:06:21 +02:00
added new tests for LhvConnectTransactionsController
This commit is contained in:
parent
2bc5f50474
commit
6166c084d3
1 changed files with 30 additions and 0 deletions
|
@ -38,4 +38,34 @@ class LhvConnectTransactionsIntegrationTest < ApplicationIntegrationTest
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_creates_invoice_and_sends_paid_status
|
||||
# Use an invoice that already has a payment reference that matches the transaction
|
||||
paid_invoice = invoices(:one)
|
||||
spy = Spy.on(EisBilling::SendInvoiceStatus, :send_info).and_return(true)
|
||||
|
||||
transaction = {
|
||||
'amount' => paid_invoice.total,
|
||||
'currency' => 'EUR',
|
||||
'date' => Time.zone.today,
|
||||
'payment_reference_number' => paid_invoice.reference_no,
|
||||
'payment_description' => 'Makstud arve'
|
||||
}
|
||||
|
||||
post eis_billing_lhv_connect_transactions_path,
|
||||
params:{ '_json' => [transaction] },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 'RECEIVED', JSON.parse(response.body)['message']
|
||||
assert spy.calls.length >= 1, "Expected at least 1 call to send_info, got #{spy.calls.length}"
|
||||
|
||||
# Check that at least one of the calls has the correct arguments
|
||||
# Since both invoices have the same reference_no, the system might use a different invoice
|
||||
# So we check that send_info is called with status 'paid' and any valid invoice number
|
||||
call_with_correct_args = spy.calls.any? do |call|
|
||||
call.args[0][:status] == 'paid' && call.args[0][:invoice_number].present?
|
||||
end
|
||||
assert call_with_correct_args, "Expected send_info to be called with status: 'paid' and a valid invoice_number"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue