mirror of
https://github.com/internetee/registry.git
synced 2025-08-13 04:59:42 +02:00
Merge pull request #2833 from internetee/adding_test_coverage/admin/bank_transactions_controller
Adding tests for admin/bank_transactions_controller
This commit is contained in:
commit
f56ddcf00b
3 changed files with 76 additions and 1 deletions
7
test/fixtures/bank_statements.yml
vendored
7
test/fixtures/bank_statements.yml
vendored
|
@ -1,3 +1,8 @@
|
|||
one:
|
||||
bank_code: '1234'
|
||||
iban: GB33BUKB20201555555555
|
||||
iban: GB33BUKB20201555555555
|
||||
|
||||
two:
|
||||
bank_code: '4321'
|
||||
iban: GB82WEST12345698765432
|
||||
|
7
test/fixtures/bank_transactions.yml
vendored
7
test/fixtures/bank_transactions.yml
vendored
|
@ -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
test/integration/admin_area/bank_transactions_test.rb
Normal file
63
test/integration/admin_area/bank_transactions_test.rb
Normal file
|
@ -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…
Add table
Add a link
Reference in a new issue