From fd9187a943f2f88bc31f8ffa65a7b780c7ba6054 Mon Sep 17 00:00:00 2001 From: olegphenomenon Date: Thu, 27 Jan 2022 14:16:19 +0200 Subject: [PATCH] added test payment status test --- .../eis_billing/payment_status_test.rb | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/integration/eis_billing/payment_status_test.rb diff --git a/test/integration/eis_billing/payment_status_test.rb b/test/integration/eis_billing/payment_status_test.rb new file mode 100644 index 000000000..f9e1e1006 --- /dev/null +++ b/test/integration/eis_billing/payment_status_test.rb @@ -0,0 +1,31 @@ +require 'test_helper' + +class PaymentStatusIntegrationTest < ApplicationIntegrationTest + setup do + @invoice = invoices(:unpaid) + sign_in users(:api_bestnames) + end + + def test_update_payment_status + payload = { + "order_reference" => @invoice.number, + "paid_at" => Time.zone.now - 2.minute, + "sum" => @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, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + end + end + + assert_equal @invoice.account_activity.activity_type, "add_credit" + + assert_response :ok + end +end