mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 11:16:00 +02:00
Reorganize tests
This commit is contained in:
parent
e4bb6b42ae
commit
8a167c4728
2 changed files with 4 additions and 4 deletions
|
@ -1,59 +0,0 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class PaymentCallbackTest < ApplicationSystemTestCase
|
||||
def setup
|
||||
super
|
||||
|
||||
@user = users(:api_bestnames)
|
||||
sign_in @user
|
||||
end
|
||||
|
||||
def test_every_pay_callback_returns_status_200
|
||||
invoice = payable_invoice
|
||||
assert_matching_bank_transaction_exists(invoice)
|
||||
|
||||
request_params = every_pay_request_params.merge(invoice_id: invoice.id)
|
||||
post "/registrar/pay/callback/every_pay", request_params
|
||||
|
||||
assert_response :ok
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def payable_invoice
|
||||
invoice = invoices(:one)
|
||||
invoice.update!(account_activity: nil)
|
||||
invoice
|
||||
end
|
||||
|
||||
def assert_matching_bank_transaction_exists(invoice)
|
||||
assert BankTransaction.find_by(
|
||||
description: invoice.order,
|
||||
currency: invoice.currency,
|
||||
iban: invoice.seller_iban
|
||||
), 'Matching bank transaction should exist'
|
||||
end
|
||||
|
||||
def every_pay_request_params
|
||||
{
|
||||
nonce: "392f2d7748bc8cb0d14f263ebb7b8932",
|
||||
timestamp: "1524136727",
|
||||
api_username: "ca8d6336dd750ddb",
|
||||
transaction_result: "completed",
|
||||
payment_reference: "fd5d27b59a1eb597393cd5ff77386d6cab81ae05067e18d530b10f3802e30b56",
|
||||
payment_state: "settled",
|
||||
amount: "12.00",
|
||||
order_reference: "e468a2d59a731ccc546f2165c3b1a6",
|
||||
account_id: "EUR3D1",
|
||||
cc_type: "master_card",
|
||||
cc_last_four_digits: "0487",
|
||||
cc_month: "10",
|
||||
cc_year: "2018",
|
||||
cc_holder_name: "John Doe",
|
||||
hmac_fields: "account_id,amount,api_username,cc_holder_name,cc_last_four_digits,cc_month,cc_type,cc_year,hmac_fields,nonce,order_reference,payment_reference,payment_state,timestamp,transaction_result",
|
||||
hmac: "efac1c732835668cd86023a7abc140506c692f0d",
|
||||
invoice_id: "12900000",
|
||||
payment_method: "every_pay"
|
||||
}
|
||||
end
|
||||
end
|
|
@ -1,89 +0,0 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class PaymentReturnTest < ApplicationSystemTestCase
|
||||
def setup
|
||||
super
|
||||
|
||||
@user = users(:api_bestnames)
|
||||
sign_in @user
|
||||
|
||||
@invoice = invoices(:one)
|
||||
end
|
||||
|
||||
def every_pay_request_params
|
||||
{
|
||||
nonce: "392f2d7748bc8cb0d14f263ebb7b8932",
|
||||
timestamp: "1524136727",
|
||||
api_username: "ca8d6336dd750ddb",
|
||||
transaction_result: "completed",
|
||||
payment_reference: "fd5d27b59a1eb597393cd5ff77386d6cab81ae05067e18d530b10f3802e30b56",
|
||||
payment_state: "settled",
|
||||
amount: "12.00",
|
||||
order_reference: "e468a2d59a731ccc546f2165c3b1a6",
|
||||
account_id: "EUR3D1",
|
||||
cc_type: "master_card",
|
||||
cc_last_four_digits: "0487",
|
||||
cc_month: "10",
|
||||
cc_year: "2018",
|
||||
cc_holder_name: "John Doe",
|
||||
hmac_fields: "account_id,amount,api_username,cc_holder_name,cc_last_four_digits,cc_month,cc_type,cc_year,hmac_fields,nonce,order_reference,payment_reference,payment_state,timestamp,transaction_result",
|
||||
hmac: "efac1c732835668cd86023a7abc140506c692f0d",
|
||||
invoice_id: "12900000",
|
||||
payment_method: "every_pay"
|
||||
}
|
||||
end
|
||||
|
||||
def bank_link_request_params
|
||||
{
|
||||
"VK_SERVICE": "1111",
|
||||
"VK_VERSION": "008",
|
||||
"VK_SND_ID": "testvpos",
|
||||
"VK_REC_ID": "seb",
|
||||
"VK_STAMP": 1,
|
||||
"VK_T_NO": "1",
|
||||
"VK_AMOUNT": "12.00",
|
||||
"VK_CURR": "EUR",
|
||||
"VK_REC_ACC": "1234",
|
||||
"VK_REC_NAME": "Eesti Internet",
|
||||
"VK_SND_ACC": "1234",
|
||||
"VK_SND_NAME": "John Doe",
|
||||
"VK_REF": "",
|
||||
"VK_MSG": "Order nr 1",
|
||||
"VK_T_DATETIME": "2018-04-01T00:30:00+0300",
|
||||
"VK_MAC": "CZZvcptkxfuOxRR88JmT4N+Lw6Hs4xiQfhBWzVYldAcRTQbcB/lPf9MbJzBE4e1/HuslQgkdCFt5g1xW2lJwrVDBQTtP6DAHfvxU3kkw7dbk0IcwhI4whUl68/QCwlXEQTAVDv1AFnGVxXZ40vbm/aLKafBYgrirB5SUe8+g9FE=",
|
||||
"VK_ENCODING": "UTF-8",
|
||||
"VK_LANG": "ENG",
|
||||
payment_method: "seb"
|
||||
}
|
||||
end
|
||||
|
||||
def test_every_pay_return_creates_activity_redirects_to_invoice_path
|
||||
request_params = every_pay_request_params.merge(invoice_id: @invoice.id)
|
||||
|
||||
post "/registrar/pay/return/every_pay", request_params
|
||||
assert_equal(302, response.status)
|
||||
assert_redirected_to(registrar_invoice_path(@invoice))
|
||||
end
|
||||
|
||||
def test_Every_Pay_return_raises_RecordNotFound
|
||||
request_params = every_pay_request_params.merge(invoice_id: "178907")
|
||||
assert_raises(ActiveRecord::RecordNotFound) do
|
||||
post "/registrar/pay/return/every_pay", request_params
|
||||
end
|
||||
end
|
||||
|
||||
def test_bank_link_return_redirects_to_invoice_paths
|
||||
request_params = bank_link_request_params.merge(invoice_id: @invoice.id)
|
||||
|
||||
post "/registrar/pay/return/seb", request_params
|
||||
assert_equal(302, response.status)
|
||||
assert_redirected_to(registrar_invoice_path(@invoice))
|
||||
end
|
||||
|
||||
def test_bank_link_return
|
||||
request_params = bank_link_request_params.merge(invoice_id: "178907")
|
||||
assert_raises(ActiveRecord::RecordNotFound) do
|
||||
post "/registrar/pay/return/seb", request_params
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue