1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00

Transactions cleanup (#817)

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
This commit is contained in:
Zach Gollwitzer 2024-05-30 20:55:18 -04:00 committed by GitHub
parent ee162bbef7
commit 4ebc08e5a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
61 changed files with 789 additions and 683 deletions

View file

@ -1,6 +1,18 @@
require "test_helper"
class Account::SyncableTest < ActiveSupport::TestCase
include ActiveJob::TestHelper
setup do
@account = accounts(:savings_with_valuation_overrides)
end
test "triggers sync job" do
assert_enqueued_with(job: AccountSyncJob, args: [ @account, Date.current ]) do
@account.sync_later(Date.current)
end
end
test "account has no balances until synced" do
account = accounts(:savings_with_valuation_overrides)

View file

@ -1,14 +1,44 @@
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 Transaction.inflows.include? inflow_transaction
assert Transaction.outflows.include? outflow_transaction
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