mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 05:09:38 +02:00
Account Activity View + Account Forms (#1406)
* Remove balance mode, sketch out refactor * Activity view checkpoint * Entry partials, checkpoint * Finish txn partial * Give entries context when editing for different turbo responses * Calculate change of balance for each entry * Account tabs consolidation * Translations, linting, brakeman updates * Account actions concern * Finalize forms, get account system tests passing * Get tests passing * Lint, rubocop, schema updates * Improve routing and stream responses * Fix broken routes * Add import option for adding accounts * Fix system test * Fix test specificity * Fix sparklines * Improve account redirects
This commit is contained in:
parent
12e4f1067d
commit
65db49273c
216 changed files with 2043 additions and 1620 deletions
|
@ -1,12 +1,14 @@
|
|||
require "test_helper"
|
||||
|
||||
class LoansControllerTest < ActionDispatch::IntegrationTest
|
||||
include AccountableResourceInterfaceTest
|
||||
|
||||
setup do
|
||||
sign_in @user = users(:family_admin)
|
||||
@account = accounts(:loan)
|
||||
end
|
||||
|
||||
test "creates loan" do
|
||||
test "creates with loan details" do
|
||||
assert_difference -> { Account.count } => 1,
|
||||
-> { Loan.count } => 1,
|
||||
-> { Account::Valuation.count } => 2,
|
||||
|
@ -17,8 +19,6 @@ class LoansControllerTest < ActionDispatch::IntegrationTest
|
|||
balance: 50000,
|
||||
currency: "USD",
|
||||
accountable_type: "Loan",
|
||||
start_date: 1.month.ago.to_date,
|
||||
start_balance: 50000,
|
||||
accountable_attributes: {
|
||||
interest_rate: 5.5,
|
||||
term_months: 60,
|
||||
|
@ -33,18 +33,18 @@ class LoansControllerTest < ActionDispatch::IntegrationTest
|
|||
assert_equal "New Loan", created_account.name
|
||||
assert_equal 50000, created_account.balance
|
||||
assert_equal "USD", created_account.currency
|
||||
assert_equal 5.5, created_account.loan.interest_rate
|
||||
assert_equal 60, created_account.loan.term_months
|
||||
assert_equal "fixed", created_account.loan.rate_type
|
||||
assert_equal 5.5, created_account.accountable.interest_rate
|
||||
assert_equal 60, created_account.accountable.term_months
|
||||
assert_equal "fixed", created_account.accountable.rate_type
|
||||
|
||||
assert_redirected_to account_path(created_account)
|
||||
assert_equal "Loan created successfully", flash[:notice]
|
||||
assert_redirected_to created_account
|
||||
assert_equal "Loan account created", flash[:notice]
|
||||
assert_enqueued_with(job: AccountSyncJob)
|
||||
end
|
||||
|
||||
test "updates loan" do
|
||||
test "updates with loan details" do
|
||||
assert_no_difference [ "Account.count", "Loan.count" ] do
|
||||
patch loan_path(@account), params: {
|
||||
patch account_path(@account), params: {
|
||||
account: {
|
||||
name: "Updated Loan",
|
||||
balance: 45000,
|
||||
|
@ -64,12 +64,12 @@ class LoansControllerTest < ActionDispatch::IntegrationTest
|
|||
|
||||
assert_equal "Updated Loan", @account.name
|
||||
assert_equal 45000, @account.balance
|
||||
assert_equal 4.5, @account.loan.interest_rate
|
||||
assert_equal 48, @account.loan.term_months
|
||||
assert_equal "fixed", @account.loan.rate_type
|
||||
assert_equal 4.5, @account.accountable.interest_rate
|
||||
assert_equal 48, @account.accountable.term_months
|
||||
assert_equal "fixed", @account.accountable.rate_type
|
||||
|
||||
assert_redirected_to account_path(@account)
|
||||
assert_equal "Loan updated successfully", flash[:notice]
|
||||
assert_redirected_to @account
|
||||
assert_equal "Loan account updated", flash[:notice]
|
||||
assert_enqueued_with(job: AccountSyncJob)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue