mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 14:36:22 +02:00
added test for lhv connect
This commit is contained in:
parent
fd9187a943
commit
d9696014ff
2 changed files with 62 additions and 6 deletions
|
@ -0,0 +1,29 @@
|
|||
require 'test_helper'
|
||||
|
||||
class LhvConnectTransactionsIntegrationTest < ApplicationIntegrationTest
|
||||
setup do
|
||||
@invoice = invoices(:unpaid)
|
||||
sign_in users(:api_bestnames)
|
||||
end
|
||||
|
||||
def test_should_saved_transaction_data
|
||||
test_transaction = OpenStruct.new(amount: 0.1,
|
||||
currency: 'EUR',
|
||||
date: Time.zone.today,
|
||||
payment_reference_number: '2199812',
|
||||
payment_description: "description 2199812")
|
||||
|
||||
lhv_transactions = []
|
||||
|
||||
3.times do
|
||||
lhv_transactions << test_transaction
|
||||
end
|
||||
|
||||
assert_difference 'BankStatement.count', 3 do
|
||||
assert_difference 'BankTransaction.count', 3 do
|
||||
post eis_billing_lhv_connect_transactions_path, params: { "_json" => JSON.parse(lhv_transactions.to_json) },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -6,17 +6,14 @@ class PaymentStatusIntegrationTest < ApplicationIntegrationTest
|
|||
sign_in users(:api_bestnames)
|
||||
end
|
||||
|
||||
def test_update_payment_status
|
||||
def test_update_payment_status_should_create_succesfully_billing_instaces
|
||||
payload = {
|
||||
"order_reference" => @invoice.number,
|
||||
"paid_at" => Time.zone.now - 2.minute,
|
||||
"sum" => @invoice.total,
|
||||
"transaction_time" => Time.zone.now - 2.minute,
|
||||
"standing_amount" => @invoice.total,
|
||||
"payment_state" => 'settled'
|
||||
}
|
||||
|
||||
p @invoice.payment_orders.count
|
||||
p BankTransaction.count
|
||||
|
||||
assert_difference -> { @invoice.payment_orders.count } do
|
||||
assert_difference -> { BankTransaction.count } do
|
||||
put eis_billing_payment_status_path, params: payload,
|
||||
|
@ -24,6 +21,36 @@ class PaymentStatusIntegrationTest < ApplicationIntegrationTest
|
|||
end
|
||||
end
|
||||
|
||||
bank_transaction = BankTransaction.order(created_at: :desc).first
|
||||
invoice_payment_order = @invoice.payment_orders.order(created_at: :desc).first
|
||||
|
||||
assert_equal bank_transaction.sum, @invoice.total
|
||||
assert_equal invoice_payment_order.status, "paid"
|
||||
assert_equal @invoice.account_activity.activity_type, "add_credit"
|
||||
|
||||
assert_response :ok
|
||||
end
|
||||
|
||||
def test_update_payment_status_should_create_failed_payment
|
||||
payload = {
|
||||
"order_reference" => @invoice.number,
|
||||
"transaction_time" => Time.zone.now - 2.minute,
|
||||
"standing_amount" => @invoice.total,
|
||||
"payment_state" => 'cancelled'
|
||||
}
|
||||
|
||||
assert_difference -> { @invoice.payment_orders.count } do
|
||||
assert_difference -> { BankTransaction.count } do
|
||||
put eis_billing_payment_status_path, params: payload,
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
end
|
||||
|
||||
bank_transaction = BankTransaction.order(created_at: :desc).first
|
||||
invoice_payment_order = @invoice.payment_orders.order(created_at: :desc).first
|
||||
|
||||
assert_equal bank_transaction.sum, @invoice.total
|
||||
assert_equal invoice_payment_order.status, "failed"
|
||||
assert_equal @invoice.account_activity.activity_type, "add_credit"
|
||||
|
||||
assert_response :ok
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue