mirror of
https://github.com/internetee/registry.git
synced 2025-08-01 23:42:04 +02:00
fixed tests
This commit is contained in:
parent
fdf70359d1
commit
8812f8da22
20 changed files with 109 additions and 165 deletions
|
@ -27,16 +27,16 @@ class AdminAreaInvoicesIntegrationTest < ApplicationIntegrationTest
|
|||
if Feature.billing_system_integrated?
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
|
||||
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
|
||||
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
||||
stub_request(:put, "http://registry:3000/eis_billing/e_invoice_response").
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
|
||||
stub_request(:post, "http://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
|
||||
visit new_admin_invoice_path
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class PaymentStatusIntegrationTest < ApplicationIntegrationTest
|
||||
setup do
|
||||
@invoice = invoices(:unpaid)
|
||||
sign_in users(:api_bestnames)
|
||||
Spy.on_instance_method(EisBilling::BaseController, :authorized).and_return(true)
|
||||
end
|
||||
|
||||
def test_update_payment_status_should_create_succesfully_billing_instaces
|
||||
if Feature.billing_system_integrated?
|
||||
payload = {
|
||||
"order_reference" => @invoice.number,
|
||||
"transaction_time" => Time.zone.now - 2.minute,
|
||||
"standing_amount" => @invoice.total,
|
||||
"payment_state" => 'settled'
|
||||
}
|
||||
|
||||
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, "paid"
|
||||
assert_equal @invoice.account_activity.activity_type, "add_credit"
|
||||
|
||||
assert_response :ok
|
||||
end
|
||||
end
|
||||
|
||||
def test_update_payment_status_should_create_failed_payment
|
||||
if Feature.billing_system_integrated?
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue