DEV: Make `find_post_using` raise only `Discourse::NotFound` (#16133)

This commit is contained in:
Jarek Radosz 2022-03-08 17:39:52 +01:00 committed by GitHub
parent c212af665c
commit 768c80c2a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -869,7 +869,7 @@ class PostsController < ApplicationController
post = finder.with_deleted.first
raise Discourse::NotFound unless post
post.topic = Topic.with_deleted.find(post.topic_id)
post.topic = Topic.with_deleted.find_by(id: post.topic_id)
if !post.topic ||
(

View File

@ -16,6 +16,12 @@ shared_examples 'finding and showing post' do
expect(response.status).to eq(200)
end
it "returns 404 when post's topic is deleted" do
post.topic.destroy!
get url
expect(response.status).to eq(404)
end
context "deleted post" do
before do
post.trash!(user)