mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-23 23:29:39 +02:00
An overhaul and cleanup of the transactions feature including: - Simplification of transactions search and filtering - Consolidation of account sync logic after transaction change - Split sidebar modal and modal into "drawer" and "modal" concepts - Refactor of transaction partials and folder organization - Cleanup turbo frames and streams for transaction updates, including new Transactions::RowsController for inline updates - Refactored and added several integration and systems tests
44 lines
1.5 KiB
Ruby
44 lines
1.5 KiB
Ruby
require "test_helper"
|
|
|
|
class TransactionTest < ActiveSupport::TestCase
|
|
setup do
|
|
@transaction = transactions(:checking_one)
|
|
end
|
|
|
|
# See: https://github.com/maybe-finance/maybe/wiki/vision#signage-of-money
|
|
test "negative amounts are inflows, positive amounts are outflows to an account" do
|
|
inflow_transaction = transactions(:checking_four)
|
|
outflow_transaction = transactions(:checking_five)
|
|
|
|
assert inflow_transaction.amount < 0
|
|
assert inflow_transaction.inflow?
|
|
|
|
assert outflow_transaction.amount >= 0
|
|
assert outflow_transaction.outflow?
|
|
end
|
|
|
|
test "triggers sync with correct start date when transaction is set to prior date" do
|
|
prior_date = @transaction.date - 1
|
|
@transaction.update! date: prior_date
|
|
|
|
@transaction.account.expects(:sync_later).with(prior_date)
|
|
@transaction.sync_account_later
|
|
end
|
|
|
|
test "triggers sync with correct start date when transaction is set to future date" do
|
|
prior_date = @transaction.date
|
|
@transaction.update! date: @transaction.date + 1
|
|
|
|
@transaction.account.expects(:sync_later).with(prior_date)
|
|
@transaction.sync_account_later
|
|
end
|
|
|
|
test "triggers sync with correct start date when transaction deleted" do
|
|
prior_transaction = transactions(:checking_two) # 12 days ago
|
|
current_transaction = transactions(:checking_one) # 5 days ago
|
|
current_transaction.destroy!
|
|
|
|
current_transaction.account.expects(:sync_later).with(prior_transaction.date)
|
|
current_transaction.sync_account_later
|
|
end
|
|
end
|