1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-21 14:19:39 +02:00
Maybe/test/controllers/transactions_controller_test.rb
Zach Gollwitzer 7d48c01833
Prepare fixture data for account sync tests (#493)
* Rename account balance field for clarity

`original_balance` and `original_currency` may infer that these values are "original" to the account.  In reality, they represent the "current" balance and currency on the account.

* Prepare fixture data for account sync testing

* Update to new field

* Fix conflicts

* Remove local schema change
2024-02-27 12:43:49 -05:00

50 lines
1.5 KiB
Ruby

require "test_helper"
class TransactionsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in @user = users(:family_admin)
@transaction = transactions(:checking_one)
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
name = "transaction_name"
assert_difference("Transaction.count") do
post transactions_url, params: { transaction: { account_id: @transaction.account_id, amount: @transaction.amount, currency: @transaction.currency, date: @transaction.date, name: } }
end
assert_redirected_to transaction_url(Transaction.find_by(name:))
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