mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-22 06:39:39 +02:00
Make balance editing easier (#976)
* Make balance editing easier * Translations * Fix money input option * Fix balance sync logic * Rework balance update flow
This commit is contained in:
parent
b002a41b35
commit
34e03c2d6a
9 changed files with 91 additions and 23 deletions
|
@ -46,6 +46,37 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
|
|||
}
|
||||
|
||||
assert_redirected_to account_url(@account)
|
||||
assert_enqueued_with job: AccountSyncJob
|
||||
assert_equal "Account updated", flash[:notice]
|
||||
end
|
||||
|
||||
test "updates account balance by creating new valuation" do
|
||||
assert_difference [ "Account::Entry.count", "Account::Valuation.count" ], 1 do
|
||||
patch account_url(@account), params: {
|
||||
account: {
|
||||
balance: 10000
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
assert_redirected_to account_url(@account)
|
||||
assert_enqueued_with job: AccountSyncJob
|
||||
assert_equal "Account updated", flash[:notice]
|
||||
end
|
||||
|
||||
test "updates account balance by editing existing valuation for today" do
|
||||
@account.entries.create! date: Date.current, amount: 6000, currency: "USD", entryable: Account::Valuation.new
|
||||
|
||||
assert_no_difference [ "Account::Entry.count", "Account::Valuation.count" ] do
|
||||
patch account_url(@account), params: {
|
||||
account: {
|
||||
balance: 10000
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
assert_redirected_to account_url(@account)
|
||||
assert_enqueued_with job: AccountSyncJob
|
||||
assert_equal "Account updated", flash[:notice]
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue