mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 08:22:05 +02:00
updated tests
This commit is contained in:
parent
ef03166fee
commit
d0236be063
21 changed files with 578 additions and 658 deletions
|
@ -24,38 +24,30 @@ class AdminAreaInvoicesIntegrationTest < ApplicationIntegrationTest
|
|||
end
|
||||
|
||||
def test_create_new_invoice
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
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").
|
||||
with(
|
||||
body: "{\"transaction_amount\":\"1200.0\",\"order_reference\":4,\"customer_name\":\"Best Names\",\"customer_email\":\"info@bestnames.test\",\"custom_field_1\":\"\",\"custom_field_2\":\"registry\",\"invoice_number\":4}",
|
||||
headers: {
|
||||
'Accept'=>'Bearer WA9UvDmzR9UcE5rLqpWravPQtdS8eDMAIynzGdSOTw==--9ZShwwij3qmLeuMJ--NE96w2PnfpfyIuuNzDJTGw==',
|
||||
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
||||
'Authorization'=>'Bearer foobar',
|
||||
'Content-Type'=>'application/json',
|
||||
'User-Agent'=>'Ruby'
|
||||
}).
|
||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
stub_request(:post, "http://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").
|
||||
with(
|
||||
headers: {
|
||||
'Accept'=>'Bearer WA9UvDmzR9UcE5rLqpWravPQtdS8eDMAIynzGdSOTw==--9ZShwwij3qmLeuMJ--NE96w2PnfpfyIuuNzDJTGw==',
|
||||
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
||||
'Authorization'=>'Bearer foobar',
|
||||
'Content-Type'=>'application/json',
|
||||
'User-Agent'=>'Ruby'
|
||||
}).
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
visit new_admin_invoice_path
|
||||
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
||||
assert_text 'Create new invoice'
|
||||
select 'Best Names', from: 'deposit_registrar_id', match: :first
|
||||
fill_in 'Amount', with: '1000'
|
||||
click_on 'Save'
|
||||
stub_request(:put, "http://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
|
||||
assert_equal page.status_code, 200
|
||||
stub_request(:post, "http://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
|
||||
visit new_admin_invoice_path
|
||||
|
||||
assert_text 'Create new invoice'
|
||||
select 'Best Names', from: 'deposit_registrar_id', match: :first
|
||||
fill_in 'Amount', with: '1000'
|
||||
click_on 'Save'
|
||||
|
||||
assert_equal page.status_code, 200
|
||||
end
|
||||
end
|
||||
|
||||
def test_visit_list_of_invoices_pages
|
||||
|
|
|
@ -6,35 +6,40 @@ class DirectoResponseTest < ApplicationIntegrationTest
|
|||
|
||||
@invoice = invoices(:one)
|
||||
@response_xml = '<?xml version="1.0" encoding="UTF-8"?><results><Result Type="0" Desc="OK" docid="1" doctype="ARVE" submit="Invoices"/></results>'
|
||||
Spy.on_instance_method(EisBilling::BaseController, :authorized).and_return(true)
|
||||
end
|
||||
|
||||
def test_should_created_directo_instance
|
||||
directo_response_from_billing = {
|
||||
response: 'this is response',
|
||||
xml_data: @response_xml,
|
||||
month: true
|
||||
}
|
||||
if Feature.billing_system_integrated?
|
||||
directo_response_from_billing = {
|
||||
response: 'this is response',
|
||||
xml_data: @response_xml,
|
||||
month: true
|
||||
}
|
||||
|
||||
assert_difference 'Directo.count', 1 do
|
||||
put eis_billing_directo_response_path, params: JSON.parse(directo_response_from_billing.to_json),
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_difference 'Directo.count', 1 do
|
||||
put eis_billing_directo_response_path, params: JSON.parse(directo_response_from_billing.to_json),
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_should_update_related_invoice
|
||||
directo_response_from_billing = {
|
||||
response: 'this is response',
|
||||
xml_data: @response_xml
|
||||
}
|
||||
if Feature.billing_system_integrated?
|
||||
directo_response_from_billing = {
|
||||
response: 'this is response',
|
||||
xml_data: @response_xml
|
||||
}
|
||||
|
||||
refute @invoice.in_directo
|
||||
refute @invoice.in_directo
|
||||
|
||||
assert_difference 'Directo.count', 1 do
|
||||
put eis_billing_directo_response_path, params: JSON.parse(directo_response_from_billing.to_json),
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_difference 'Directo.count', 1 do
|
||||
put eis_billing_directo_response_path, params: JSON.parse(directo_response_from_billing.to_json),
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
|
||||
@invoice.reload
|
||||
assert @invoice.in_directo
|
||||
end
|
||||
|
||||
@invoice.reload
|
||||
assert @invoice.in_directo
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,25 +4,39 @@ class LhvConnectTransactionsIntegrationTest < ApplicationIntegrationTest
|
|||
setup do
|
||||
@invoice = invoices(:unpaid)
|
||||
sign_in users(:api_bestnames)
|
||||
Spy.on_instance_method(EisBilling::BaseController, :authorized).and_return(true)
|
||||
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")
|
||||
if Feature.billing_system_integrated?
|
||||
test_transaction_1 = OpenStruct.new(amount: 0.1,
|
||||
currency: 'EUR',
|
||||
date: Time.zone.today,
|
||||
payment_reference_number: '2199812',
|
||||
payment_description: "description 2199812")
|
||||
|
||||
lhv_transactions = []
|
||||
test_transaction_2 = OpenStruct.new(amount: 0.1,
|
||||
currency: 'EUR',
|
||||
date: Time.zone.today,
|
||||
payment_reference_number: '2199813',
|
||||
payment_description: "description 2199813")
|
||||
|
||||
3.times do
|
||||
lhv_transactions << test_transaction
|
||||
end
|
||||
test_transaction_3 = OpenStruct.new(amount: 0.1,
|
||||
currency: 'EUR',
|
||||
date: Time.zone.today,
|
||||
payment_reference_number: '2199814',
|
||||
payment_description: "description 2199814")
|
||||
|
||||
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' }
|
||||
lhv_transactions = []
|
||||
lhv_transactions << test_transaction_1
|
||||
lhv_transactions << test_transaction_2
|
||||
lhv_transactions << test_transaction_3
|
||||
|
||||
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
|
||||
|
|
|
@ -4,55 +4,60 @@ 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
|
||||
payload = {
|
||||
"order_reference" => @invoice.number,
|
||||
"transaction_time" => Time.zone.now - 2.minute,
|
||||
"standing_amount" => @invoice.total,
|
||||
"payment_state" => 'settled'
|
||||
}
|
||||
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' }
|
||||
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
|
||||
|
||||
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'
|
||||
}
|
||||
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' }
|
||||
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
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue