FIX: don't error topic RSS when posts are deleted (#11641)

This commit is contained in:
Krzysztof Kotlarek 2021-01-08 11:16:15 +11:00 committed by GitHub
parent 1cf9231045
commit 4928f9cceb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -840,6 +840,8 @@ class TopicsController < ApplicationController
end
def feed
raise Discourse::NotFound if !Post.exists?(topic_id: params[:topic_id])
@topic_view = TopicView.new(params[:topic_id])
discourse_expires_in 1.minute
render 'topics/show', formats: [:rss]

View File

@ -2519,6 +2519,12 @@ RSpec.describe TopicsController do
expect(response.body).to_not include("/forum/forum")
expect(response.body).to include("http://test.localhost/forum/t/#{topic.slug}")
end
it 'returns 404 when posts are deleted' do
topic.posts.each(&:trash!)
get "/t/foo/#{topic.id}.rss"
expect(response.status).to eq(404)
end
end
describe '#invite_group' do