mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 16:32:04 +02:00
Merge pull request #1939 from internetee/1937-lhv-connect-check-invoices-marked-paid-by-admin
added test for transaction with binded invoice which already paid
This commit is contained in:
commit
f7455008c1
9 changed files with 131 additions and 12 deletions
|
@ -4,6 +4,23 @@ class AdminAreaInvoicesIntegrationTest < ApplicationIntegrationTest
|
|||
setup do
|
||||
@invoice = invoices(:one)
|
||||
sign_in users(:admin)
|
||||
|
||||
@account = accounts(:cash)
|
||||
@registrar = registrars(:bestnames)
|
||||
end
|
||||
|
||||
def test_cancel_paid_invoice
|
||||
@invoice.account_activity.update(sum: 10)
|
||||
assert @invoice.paid?
|
||||
|
||||
assert_equal @registrar.balance, 100
|
||||
|
||||
assert_no_difference 'Invoice.count' do
|
||||
assert_difference 'AccountActivity.count' do
|
||||
post cancel_paid_admin_invoices_path(id: @invoice.id) + "?invoice_id=#{@invoice.id}"
|
||||
end
|
||||
end
|
||||
assert_equal @registrar.balance, 90
|
||||
end
|
||||
|
||||
def test_create_new_invoice
|
||||
|
|
|
@ -13,6 +13,9 @@ class ProcessPaymentsTaskTest < ActiveSupport::TestCase
|
|||
total: payment_amount,
|
||||
currency: @payment_currency,
|
||||
reference_no: @payment_reference_number)
|
||||
@account_activity = account_activities(:one)
|
||||
@account = accounts(:cash)
|
||||
|
||||
Setting.registry_iban = beneficiary_iban
|
||||
|
||||
Lhv::ConnectApi.class_eval do
|
||||
|
@ -29,6 +32,36 @@ class ProcessPaymentsTaskTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_cannot_create_new_invoice_if_transaction_binded_to_paid_invoice
|
||||
assert_not @invoice.paid?
|
||||
|
||||
@account_activity.update(activity_type: "add_credit", bank_transaction: nil, created_at: Time.zone.today - 1.day, creator_str: 'AdminUser')
|
||||
@invoice.update(account_activity: @account_activity, total: @payment_amount)
|
||||
assert @invoice.paid?
|
||||
|
||||
assert_no_difference 'AccountActivity.count' do
|
||||
assert_no_difference 'Invoice.count' do
|
||||
assert_no_difference -> {@account.balance} do
|
||||
capture_io { run_task }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_if_invoice_is_overdue_than_48_hours
|
||||
assert_not @invoice.paid?
|
||||
|
||||
@account_activity.update(activity_type: "add_credit", bank_transaction: nil, created_at: Time.zone.today - 3.days, creator_str: 'AdminUser')
|
||||
@invoice.update(account_activity: @account_activity, total: @payment_amount)
|
||||
assert @invoice.paid?
|
||||
|
||||
assert_difference 'AccountActivity.count' do
|
||||
assert_difference 'Invoice.count' do
|
||||
capture_io { run_task }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_doubles_are_valid
|
||||
assert Lhv::ConnectApi.method_defined?(:credit_debit_notification_messages)
|
||||
assert Lhv::ConnectApi::Messages::CreditDebitNotification.method_defined?(:bank_account_iban)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue