1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 05:09:38 +02:00

Account::Entry Delegated Type (namespace updates part 7) (#923)

* Initial entryable models

* Update transfer and tests

* Update transaction controllers and tests

* Update sync process to use new entries model

* Get dashboard working again

* Update transfers, imports, and accounts to use Account::Entry

* Update system tests

* Consolidate transaction management into entries controller

* Add permitted partial key helper

* Move account transactions list to entries controller

* Delegate transaction entries search

* Move transfer relation to entry

* Update bulk transaction management flows to use entries

* Remove test code

* Test fix attempt

* Update demo data script

* Consolidate remaining transaction partials to entries

* Consolidate valuations controller to entries controller

* Lint fix

* Remove unused files, additional cleanup

* Add back valuation creation

* Make migrations fully reversible

* Stale routes cleanup

* Migrations reversible fix

* Move types to entryable concern

* Fix search when no entries found

* Remove more unused code
This commit is contained in:
Zach Gollwitzer 2024-07-01 10:49:43 -04:00 committed by GitHub
parent 320954282a
commit c3314e62d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
105 changed files with 2150 additions and 1576 deletions

View file

@ -4,17 +4,25 @@ class TransactionsTest < ApplicationSystemTestCase
setup do
sign_in @user = users(:family_admin)
@latest_transactions = @user.family.transactions.ordered.limit(20).to_a
@page_size = 10
@latest_transactions = @user.family.entries
.account_transactions
.without_transfers
.reverse_chronological
.limit(20).to_a
@test_category = @user.family.categories.create! name: "System Test Category"
@test_merchant = @user.family.merchants.create! name: "System Test Merchant"
@target_txn = @user.family.accounts.first.transactions.create! \
@target_txn = @user.family.accounts.first.entries.create! \
name: "Oldest transaction",
date: 10.years.ago.to_date,
category: @test_category,
merchant: @test_merchant,
amount: 100
currency: @user.family.currency,
amount: 100,
entryable: Account::Transaction.new(category: @test_category,
merchant: @test_merchant)
visit transactions_url
visit transactions_url(per_page: @page_size)
end
test "can search for a transaction" do
@ -45,7 +53,7 @@ class TransactionsTest < ApplicationSystemTestCase
within "#transaction-search-filters" do
assert_text @target_txn.account.name
assert_text @target_txn.category.name
assert_text @target_txn.account_transaction.category.name
end
end
@ -75,22 +83,22 @@ class TransactionsTest < ApplicationSystemTestCase
click_button "Apply"
end
assert_text "No transactions found"
assert_text "No entries found"
# Page reload doesn't affect results
visit current_url
assert_text "No transactions found"
assert_text "No entries found"
within "ul#transaction-search-filters" do
find("li", text: @target_txn.account.name).first("a").click
find("li", text: "on or after #{10.days.ago.to_date}").first("a").click
find("li", text: "on or before #{Date.current}").first("a").click
find("li", text: @target_txn.category.name).first("a").click
find("li", text: @target_txn.merchant.name).first("a").click
find("li", text: @target_txn.account_transaction.category.name).first("a").click
find("li", text: @target_txn.account_transaction.merchant.name).first("a").click
end
assert_selector "#" + dom_id(@user.family.transactions.ordered.first), count: 1
assert_selector "#" + dom_id(@user.family.entries.reverse_chronological.first), count: 1
end
test "can select and deselect entire page of transactions" do
@ -132,17 +140,15 @@ class TransactionsTest < ApplicationSystemTestCase
private
def number_of_transactions_on_page
page_size = 10
[ @user.family.transactions.where(transfer_id: nil).count, page_size ].min
[ @user.family.entries.without_transfers.count, @page_size ].min
end
def all_transactions_checkbox
find("#selection_transaction")
find("#selection_entry")
end
def date_transactions_checkbox(date)
find("#selection_transaction_#{date}")
find("#selection_entry_#{date}")
end
def transaction_checkbox(transaction)
@ -151,9 +157,9 @@ class TransactionsTest < ApplicationSystemTestCase
def assert_selection_count(count)
if count == 0
assert_no_selector("#transaction-selection-bar")
assert_no_selector("#entry-selection-bar")
else
within "#transaction-selection-bar" do
within "#entry-selection-bar" do
assert_text "#{count} transaction#{count == 1 ? "" : "s"} selected"
end
end