Merge pull request #2832 from internetee/adding_test_coverage/admin/bank_statements_controller

Adding tests for admin/bank_statements_controller
This commit is contained in:
Martin 2025-08-06 13:24:02 +03:00 committed by GitHub
commit 502443b168
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,44 @@
require 'test_helper'
class AdminAreaBankStatementsIntegrationTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers
setup do
sign_in users(:admin)
@bank_statement = bank_statements(:one)
end
def test_index_page_accessible
get admin_bank_statements_path
assert_response :success
assert_includes response.body, 'Bank statements'
end
def test_creates_bank_statement
params = {
bank_statement: {
bank_code: '9876',
iban: 'GB82WEST12345698765432'
}
}
assert_difference 'BankStatement.count', +1 do
post admin_bank_statements_path, params: params
end
statement = BankStatement.last
assert_redirected_to admin_bank_statement_path(statement)
follow_redirect!
assert_response :success
assert_includes flash[:notice], I18n.t('record_created')
end
def test_bind_invoices_sets_flash_when_nothing_binded
post bind_invoices_admin_bank_statement_path(@bank_statement)
assert_redirected_to admin_bank_statement_path(@bank_statement)
follow_redirect!
assert_response :success
assert_equal I18n.t('no_invoices_were_binded'), flash[:alert]
end
end