mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 11:16:00 +02:00
Add EveryPay payments
* Refactor BankLink into Payments::BankLink, add Payments::EveryPay * Write tests for existing invoice views * Write basic tests for Payments module
This commit is contained in:
parent
f7c2b25a66
commit
c5591b4828
32 changed files with 818 additions and 31 deletions
39
test/integration/registrar/invoices/list_test.rb
Normal file
39
test/integration/registrar/invoices/list_test.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ListInvoicesTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
super
|
||||
|
||||
@user = users(:api_bestnames)
|
||||
@registrar_invoices = @user.registrar.invoices
|
||||
login_as @user
|
||||
end
|
||||
|
||||
def test_show_balance
|
||||
visit registrar_invoices_path
|
||||
assert_text "Your current account balance is 100,00 EUR"
|
||||
end
|
||||
|
||||
|
||||
def test_show_single_invoice
|
||||
@invoice = invoices(:valid)
|
||||
@registrar_invoices << @invoice
|
||||
|
||||
visit registrar_invoices_path
|
||||
assert_text "Unpaid", count: 1
|
||||
assert_text "Invoice no.", count: 1
|
||||
end
|
||||
|
||||
# This bastard fails, only unpaid invoice is attached to the registrar
|
||||
# TODO: Fix and uncomment
|
||||
# def test_show_multiple_invoices
|
||||
# @invoices = invoices
|
||||
# @invoices.each do |invoice|
|
||||
# @registrar_invoices << invoice
|
||||
# end
|
||||
|
||||
# visit registrar_invoices_path
|
||||
# assert_text "Unpaid", count: 2
|
||||
# assert_text "Invoice no.", count: 2
|
||||
# end
|
||||
end
|
|
@ -0,0 +1,63 @@
|
|||
require 'test_helper'
|
||||
|
||||
class NewInvoicePaymentTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
super
|
||||
|
||||
@original_methods = ENV['payment_methods']
|
||||
@original_seb_URL = ENV['seb_payment_url']
|
||||
@original_bank_certificate = ENV['seb_bank_certificate']
|
||||
@original_seller_certificate = ENV['seller_certificate']
|
||||
@original_ep_url = ENV['every_pay_payment_url']
|
||||
ENV['payment_methods'] = 'seb, swed, every_pay'
|
||||
ENV['seb_payment_url'] = 'https://example.com/seb_url'
|
||||
ENV['seb_seller_account'] = 'SEB'
|
||||
ENV['seb_bank_certificate'] = 'test/fixtures/files/seb_bank_cert.pem'
|
||||
ENV['seb_seller_certificate'] = 'test/fixtures/files/seb_seller_key.pem'
|
||||
ENV['every_pay_payment_url'] = 'https://example.com/every_pay_url'
|
||||
|
||||
@user = users(:api_bestnames)
|
||||
login_as @user
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
|
||||
ENV['every_pay_payment_url'] = @original_ep_url
|
||||
ENV['payment_methods'] = @original_methods
|
||||
ENV['seb_payment_url'] = @original_seb_URL
|
||||
ENV['seb_bank_certificate'] = @original_bank_certificate
|
||||
ENV['seb_seller_certificate'] = @original_seller_certificate
|
||||
end
|
||||
|
||||
def create_invoice_and_visit_its_page
|
||||
visit registrar_invoices_path
|
||||
click_link_or_button 'Add deposit'
|
||||
fill_in 'Amount', with: '200.00'
|
||||
fill_in 'Description', with: 'My first invoice'
|
||||
click_link_or_button 'Add'
|
||||
end
|
||||
|
||||
def test_create_new_SEB_payment
|
||||
create_invoice_and_visit_its_page
|
||||
click_link_or_button 'Seb'
|
||||
form = page.find('form')
|
||||
assert_equal 'https://example.com/seb_url', form['action']
|
||||
assert_equal 'post', form['method']
|
||||
assert_equal '240.00', form.find_by_id('VK_AMOUNT', visible: false).value
|
||||
assert_equal 'Order nr. 13150', form.find_by_id('VK_MSG', visible: false).value
|
||||
end
|
||||
|
||||
def test_create_new_Every_Pay_payment
|
||||
create_invoice_and_visit_its_page
|
||||
click_link_or_button 'Every pay'
|
||||
expected_hmac_fields = 'account_id,amount,api_username,callback_url,' +
|
||||
'customer_url,hmac_fields,nonce,order_reference,timestamp,transaction_type'
|
||||
|
||||
form = page.find('form')
|
||||
assert_equal 'https://example.com/every_pay_url', form['action']
|
||||
assert_equal 'post', form['method']
|
||||
assert_equal expected_hmac_fields, form.find_by_id('hmac_fields', visible: false).value
|
||||
assert_equal '240.0', form.find_by_id('amount', visible: false).value
|
||||
end
|
||||
end
|
67
test/integration/registrar/invoices/new_test.rb
Normal file
67
test/integration/registrar/invoices/new_test.rb
Normal file
|
@ -0,0 +1,67 @@
|
|||
require 'test_helper'
|
||||
|
||||
class NewInvoiceTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
super
|
||||
login_as users(:api_bestnames)
|
||||
end
|
||||
|
||||
def test_show_balance
|
||||
visit registrar_invoices_path
|
||||
assert_text "Your current account balance is 100,00 EUR"
|
||||
end
|
||||
|
||||
def test_create_new_invoice_with_positive_amount
|
||||
visit registrar_invoices_path
|
||||
click_link_or_button 'Add deposit'
|
||||
fill_in 'Amount', with: '200.00'
|
||||
fill_in 'Description', with: 'My first invoice'
|
||||
|
||||
assert_difference 'Invoice.count', 1 do
|
||||
click_link_or_button 'Add'
|
||||
end
|
||||
|
||||
assert_text 'Please pay the following invoice'
|
||||
assert_text 'Invoice no. 131050'
|
||||
assert_text 'Total without VAT 200,00'
|
||||
assert_text 'Pay invoice'
|
||||
end
|
||||
|
||||
def test_create_new_invoices_and_display_a_list_of_them
|
||||
visit registrar_invoices_path
|
||||
click_link_or_button 'Add deposit'
|
||||
fill_in 'Amount', with: '200.00'
|
||||
fill_in 'Description', with: 'My first invoice'
|
||||
click_link_or_button 'Add'
|
||||
|
||||
visit registrar_invoices_path
|
||||
click_link_or_button 'Add deposit'
|
||||
fill_in 'Amount', with: '300.00'
|
||||
fill_in 'Description', with: 'My second invoice'
|
||||
click_link_or_button 'Add'
|
||||
|
||||
visit registrar_invoices_path
|
||||
assert_text "Unpaid", count: 2
|
||||
assert_text "Invoice no. 131050"
|
||||
assert_text "Invoice no. 131051"
|
||||
assert_text "240,00"
|
||||
assert_text "360,00"
|
||||
end
|
||||
|
||||
# This test case should fail once issue #651 gets fixed
|
||||
def test_create_new_invoice_with_amount_0_goes_through
|
||||
visit registrar_invoices_path
|
||||
click_link_or_button 'Add deposit'
|
||||
fill_in 'Amount', with: '0.00'
|
||||
fill_in 'Description', with: 'My first invoice'
|
||||
|
||||
assert_difference 'Invoice.count', 1 do
|
||||
click_link_or_button 'Add'
|
||||
end
|
||||
|
||||
assert_text 'Please pay the following invoice'
|
||||
assert_text 'Invoice no. 131050'
|
||||
assert_text 'Total without VAT 0,00'
|
||||
assert_text 'Pay invoice'
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue