mirror of
https://github.com/we-promise/sure.git
synced 2026-09-05 23:01:26 +00:00
fix(transactions): Resolve N+1 query in bulk update controller (#3072)
* fix(transactions): Resolve N+1 query in bulk update controller * Test transaction bulk update eager loading --------- Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com> Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
This commit is contained in:
co-authored by
sentry[bot] <39604003+sentry[bot]@users.noreply.github.com>
Juan José Mata
parent
fb47e40247
commit
695c1b4190
@@ -33,6 +33,24 @@ class Transactions::BulkUpdatesControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
test "bulk update preloads transaction records" do
|
||||
transaction_ids = @user.family.entries.transactions.limit(4).pluck(:id)
|
||||
|
||||
queries = capture_sql_queries do
|
||||
post transactions_bulk_update_url, params: {
|
||||
bulk_update: {
|
||||
entry_ids: transaction_ids,
|
||||
notes: "Updated in bulk"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
assert_redirected_to transactions_url
|
||||
assert_empty queries.grep(
|
||||
/SELECT "transactions"\.\* FROM "transactions" WHERE "transactions"\."id" =/
|
||||
)
|
||||
end
|
||||
|
||||
test "bulk update preserves tags when tag_ids not provided" do
|
||||
transaction_entry = @user.family.entries.transactions.first
|
||||
original_tags = [ Tag.first, Tag.second ]
|
||||
|
||||
Reference in New Issue
Block a user