Add ON DELETE CASCADE to rejected_transfers foreign keys (#2211)

This commit is contained in:
Kelvinchen03
2026-06-16 11:22:59 -04:00
committed by GitHub
parent 844cba2fd3
commit 11bba13601
3 changed files with 37 additions and 2 deletions

View File

@@ -21,4 +21,28 @@ class Transactions::BulkDeletionsControllerTest < ActionDispatch::IntegrationTes
assert_redirected_to transactions_url
assert_equal "#{delete_count} transactions deleted", flash[:notice]
end
test "bulk delete with rejected transfers" do
entry = entries(:transaction)
other_entry = entries(:transfer_out)
# Create a rejected_transfer referencing the entry's transaction
RejectedTransfer.create!(
inflow_transaction: entry.entryable,
outflow_transaction: other_entry.entryable
)
assert_difference "RejectedTransfer.count", -1 do
assert_difference [ "Transaction.count", "Entry.count" ], -1 do
post transactions_bulk_deletion_url, params: {
bulk_delete: {
entry_ids: [ entry.id ]
}
}
end
end
assert_redirected_to transactions_url
assert_equal "1 transaction deleted", flash[:notice]
end
end