2024-06-19 06:52:08 -04:00
|
|
|
require "test_helper"
|
|
|
|
|
2024-06-20 13:32:44 -04:00
|
|
|
class Account::TransfersControllerTest < ActionDispatch::IntegrationTest
|
2024-06-19 06:52:08 -04:00
|
|
|
setup do
|
|
|
|
sign_in users(:family_admin)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should get new" do
|
2024-06-20 13:32:44 -04:00
|
|
|
get new_account_transfer_url
|
2024-06-19 06:52:08 -04:00
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
test "can create transfers" do
|
2024-06-20 13:32:44 -04:00
|
|
|
assert_difference "Account::Transfer.count", 1 do
|
|
|
|
post account_transfers_url, params: {
|
|
|
|
account_transfer: {
|
2024-07-10 11:22:59 -04:00
|
|
|
from_account_id: accounts(:depository).id,
|
|
|
|
to_account_id: accounts(:credit_card).id,
|
2024-06-19 06:52:08 -04:00
|
|
|
date: Date.current,
|
|
|
|
amount: 100,
|
|
|
|
name: "Test Transfer"
|
|
|
|
}
|
|
|
|
}
|
2024-07-04 12:57:26 +02:00
|
|
|
assert_enqueued_with job: AccountSyncJob
|
2024-06-19 06:52:08 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
test "can destroy transfer" do
|
2024-06-24 11:58:39 -04:00
|
|
|
assert_difference -> { Account::Transfer.count } => -1, -> { Account::Transaction.count } => 0 do
|
2024-07-10 11:22:59 -04:00
|
|
|
delete account_transfer_url(account_transfers(:one))
|
2024-06-19 06:52:08 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|