mirror of
https://github.com/we-promise/sure.git
synced 2026-07-20 08:45:22 +00:00
Add ON DELETE CASCADE to rejected_transfers foreign keys (#2211)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user