FIX: remove post-action when a post is permanently deleted (#11242)

Followup of https://github.com/discourse/discourse/pull/11115

When we permanently remove the post, we should remove related post-actions as well.
This commit is contained in:
Krzysztof Kotlarek
2020-11-17 07:40:36 +11:00
committed by GitHub
parent 475b4892e3
commit 7f56abac90
2 changed files with 6 additions and 2 deletions

View File

@@ -965,6 +965,7 @@ describe PostDestroyer do
describe "permanent destroy" do
fab!(:private_message_topic) { Fabricate(:private_message_topic) }
fab!(:private_post) { Fabricate(:private_message_post, topic: private_message_topic) }
fab!(:post_action) { Fabricate(:post_action, post: private_post) }
fab!(:reply) { Fabricate(:private_message_post, topic: private_message_topic) }
it "destroys the post and topic if deleting first post" do
PostDestroyer.new(reply.user, reply, permanent: true).destroy
@@ -974,6 +975,7 @@ describe PostDestroyer do
PostDestroyer.new(private_post.user, private_post, permanent: true).destroy
expect { private_post.reload }.to raise_error(ActiveRecord::RecordNotFound)
expect { private_message_topic.reload }.to raise_error(ActiveRecord::RecordNotFound)
expect { post_action.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
it 'soft delete if not creator of post or not private message' do