Cleanup code and environment variables

This commit is contained in:
Maciej Szlosarczyk 2018-04-19 09:53:56 +03:00
parent d7dc1017b0
commit 1cca930744
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765
12 changed files with 38 additions and 265 deletions

View file

@ -12,28 +12,15 @@ class ListInvoicesTest < ActionDispatch::IntegrationTest
assert_text "Your current account balance is 100,00 EUR"
end
def test_show_single_invoice
@invoice = invoices(:valid)
@registrar_invoices = []
@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(:valid, :cancelled)
@invoices = invoices
@registrar_invoices = []
@invoices.each do |invoice|
@registrar_invoices << invoice
end
visit registrar_invoices_path
assert_text "Unpaid", count: 2
assert_text "Invoice no.", count: 2
assert_text "Unpaid", count: 5
assert_text "Invoice no.", count: 7
end
end

View file

@ -2,33 +2,10 @@ require 'test_helper'
class NewInvoicePaymentTest < ActionDispatch::IntegrationTest
setup do
@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)
@original_vat_rate = @user.registrar.vat_rate
@user.registrar.vat_rate = 0.2
login_as @user
end
teardown do
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
@user.registrar.vat_rate = @original_vat_rate
end
def create_invoice_and_visit_its_page
visit registrar_invoices_path
click_link_or_button 'Add deposit'
@ -41,20 +18,19 @@ class NewInvoicePaymentTest < ActionDispatch::IntegrationTest
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 'https://www.seb.ee/cgi-bin/dv.sh/ipank.r', form['action']
assert_equal 'post', form['method']
assert_equal '220.00', form.find_by_id('VK_AMOUNT', visible: false).value
end
def test_create_new_Every_Pay_payment
create_invoice_and_visit_its_page
save_and_open_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 'https://igw-demo.every-pay.com/transactions/', form['action']
assert_equal 'post', form['method']
assert_equal expected_hmac_fields, form.find_by_id('hmac_fields', visible: false).value
assert_equal '220.0', form.find_by_id('amount', visible: false).value

View file

@ -35,27 +35,6 @@ class NewInvoiceTest < ActionDispatch::IntegrationTest
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