mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: permanent delete of posts by deleted users (#28992)
Permanently deleting posts that no longer have a user associated was not working as expected because of UserAction.log which expected user_id to be present.
This commit is contained in:
@@ -60,8 +60,8 @@ class UserActionManager
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.post_rows(post)
|
def self.post_rows(post)
|
||||||
# first post gets nada
|
# first post gets nada or if the author has been deleted
|
||||||
return [] if post.is_first_post? || post.topic.blank?
|
return [] if post.is_first_post? || post.topic.blank? || post.user.blank?
|
||||||
|
|
||||||
row = {
|
row = {
|
||||||
action_type: UserAction::REPLY,
|
action_type: UserAction::REPLY,
|
||||||
|
|||||||
@@ -1145,6 +1145,15 @@ RSpec.describe PostDestroyer do
|
|||||||
expect { regular_post.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
expect { regular_post.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||||
expect { topic.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
expect { topic.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "destroys the post when force_destroy is true for posts by deleted users" do
|
||||||
|
regular_post = Fabricate(:post, post_number: 2)
|
||||||
|
UserDestroyer.new(admin).destroy(regular_post.user, delete_posts: true)
|
||||||
|
regular_post.reload
|
||||||
|
|
||||||
|
PostDestroyer.new(moderator, regular_post, force_destroy: true).destroy
|
||||||
|
expect { regular_post.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "publishes messages to subscribers" do
|
describe "publishes messages to subscribers" do
|
||||||
|
|||||||
Reference in New Issue
Block a user