Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion test/fixtures/bank_statements.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
one:
bank_code: '1234'
iban: GB33BUKB20201555555555
iban: GB33BUKB20201555555555

two:
bank_code: '4321'
iban: GB82WEST12345698765432

7 changes: 7 additions & 0 deletions test/fixtures/bank_transactions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ one:
currency: EUR
description: Order nr 1 from registrar 1234567 second number 2345678
iban: US75512108001245126199

with_statement:
bank_statement: two
sum: 1
currency: EUR
description: Order nr 1 from registrar 1234567 second number 2345678
iban: US75512108001245126199
63 changes: 63 additions & 0 deletions test/integration/admin_area/bank_transactions_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
require 'test_helper'

class AdminAreaBankTransactionsIntegrationTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers

setup do
sign_in users(:admin)
@bank_statement = bank_statements(:one)
@bank_transaction = bank_transactions(:with_statement)
end

def test_new_page_accessible
get new_admin_bank_statement_bank_transaction_path(@bank_statement)
assert_response :success
end

def test_creates_bank_transaction
params = {
bank_transaction: {
description: 'Payment for invoice',
sum: '50.00',
currency: 'EUR'
}
}

assert_difference 'BankTransaction.count', +1 do
post admin_bank_statement_bank_transactions_path(@bank_statement), params: params
end

transaction = BankTransaction.last
assert_redirected_to admin_bank_transaction_path(transaction)
follow_redirect!
assert_response :success
assert_includes flash[:notice], I18n.t('record_created')
end

def test_bind_invoice_sets_flash_when_invoice_not_found
patch bind_admin_bank_transaction_path(@bank_transaction), params: { invoice_no: 'INVALID123' }

assert_response :success
assert_equal I18n.t('failed_to_create_record'), flash[:alert]
end

def test_updates_bank_transaction
new_description = 'Updated description'

patch admin_bank_transaction_path(@bank_transaction), params: {
bank_transaction: {
description: new_description,
sum: '1,50'
}
}

assert_redirected_to admin_bank_transaction_path(@bank_transaction)
follow_redirect!
assert_response :success
assert_equal I18n.t('record_updated'), flash[:notice]

@bank_transaction.reload
assert_equal new_description, @bank_transaction.description
assert_in_delta 1.5, @bank_transaction.sum.to_f, 0.0001
end
end
Loading