FIX: Pending post deletion by creator (#23130)

`ReviewableQueuedPost` got refactored a while back to use the more
appropriate `target_created_by` for the user of the post being queued
instead of `created_by`. The change was not extended to the `DELETE
/review/:id` endpoint leading to error responses for a user attempting
to deleting their own queued post.

This fix extends the `Reviewable` lookup implementation in
`ReviewablesController#destroy` and Guardian implementation to account
for this change.
This commit is contained in:
Selase Krakani
2023-08-18 15:30:59 +00:00
committed by GitHub
parent 4661bcb5ea
commit 87ebbec9b2
5 changed files with 19 additions and 6 deletions

View File

@ -4389,7 +4389,7 @@ RSpec.describe Guardian do
context "when attempting to destroy your own reviewable" do
it "returns true" do
queued_post = Fabricate(:reviewable_queued_post, created_by: user)
queued_post = Fabricate(:reviewable_queued_post, target_created_by: user)
env =
create_request_env(path: "/review/#{queued_post.id}.json").merge(
{ "REQUEST_METHOD" => "DELETE" },