mirror of
https://github.com/we-promise/sure.git
synced 2026-05-29 07:24:55 +00:00
fix : account destroyed cascade transfer destruction then … (#1795)
* fix: cascade destroy transfers and reset transaction kind on account destruction. * Add rescue no method to transfer transaction reset --------- Co-authored-by: arumaio <aruma.pro+git@protonmail.com>
This commit is contained in:
@@ -382,4 +382,41 @@ class AccountTest < ActiveSupport::TestCase
|
||||
assert_equal [ provider_holding.id, second_provider_holding.id ].sort, account.current_holdings.pluck(:id).sort
|
||||
assert_equal %w[CHF EUR], account.current_holdings.pluck(:currency).sort
|
||||
end
|
||||
|
||||
test "on account destroyed cascade transfer destroyed" do
|
||||
outflow_account = @family.accounts.create!({
|
||||
owner: @admin,
|
||||
name: "test_account_outflow",
|
||||
balance: 100,
|
||||
currency: "USD",
|
||||
accountable_type: "Depository",
|
||||
accountable_attributes: {}
|
||||
})
|
||||
inflow_account = @family.accounts.create!({
|
||||
owner: @admin,
|
||||
name: "test_account_inflow",
|
||||
balance: 100,
|
||||
currency: "USD",
|
||||
accountable_type: "Depository",
|
||||
accountable_attributes: {}
|
||||
})
|
||||
|
||||
transfer = create_transfer(
|
||||
from_account: outflow_account,
|
||||
to_account: inflow_account,
|
||||
amount: 50
|
||||
)
|
||||
|
||||
outflow_transaction = transfer.outflow_transaction
|
||||
|
||||
outflow_transaction.reload
|
||||
assert_equal "funds_movement", outflow_transaction.kind
|
||||
|
||||
inflow_account.destroy!
|
||||
|
||||
assert_raises(ActiveRecord::RecordNotFound) { transfer.reload }
|
||||
|
||||
outflow_transaction.reload
|
||||
assert_equal "standard", outflow_transaction.kind
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user