2024-02-23 21:34:33 -05:00
|
|
|
require "test_helper"
|
|
|
|
|
|
|
|
class TransactionsControllerTest < ActionDispatch::IntegrationTest
|
|
|
|
setup do
|
2024-02-27 12:43:49 -05:00
|
|
|
sign_in @user = users(:family_admin)
|
|
|
|
@transaction = transactions(:checking_one)
|
2024-02-23 21:34:33 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
test "should get index" do
|
|
|
|
get transactions_url
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should get new" do
|
|
|
|
get new_transaction_url
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should create transaction" do
|
2024-02-26 22:29:28 +11:00
|
|
|
name = "transaction_name"
|
2024-02-23 21:34:33 -05:00
|
|
|
assert_difference("Transaction.count") do
|
2024-02-26 22:29:28 +11:00
|
|
|
post transactions_url, params: { transaction: { account_id: @transaction.account_id, amount: @transaction.amount, currency: @transaction.currency, date: @transaction.date, name: } }
|
2024-02-23 21:34:33 -05:00
|
|
|
end
|
|
|
|
|
2024-03-18 11:21:00 -04:00
|
|
|
assert_redirected_to transactions_url
|
2024-02-23 21:34:33 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
test "should show transaction" do
|
|
|
|
get transaction_url(@transaction)
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should get edit" do
|
|
|
|
get edit_transaction_url(@transaction)
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should update transaction" do
|
|
|
|
patch transaction_url(@transaction), params: { transaction: { account_id: @transaction.account_id, amount: @transaction.amount, currency: @transaction.currency, date: @transaction.date, name: @transaction.name } }
|
|
|
|
assert_redirected_to transaction_url(@transaction)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should destroy transaction" do
|
|
|
|
assert_difference("Transaction.count", -1) do
|
|
|
|
delete transaction_url(@transaction)
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_redirected_to transactions_url
|
|
|
|
end
|
|
|
|
end
|