mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
FIX: Recovered posts with no user will be taken over by system user (#8834)
This commit is contained in:
@ -1159,7 +1159,7 @@ describe Guardian do
|
||||
PostDestroyer.new(moderator, topic.first_post).destroy
|
||||
topic.first_post.user.destroy!
|
||||
|
||||
expect(Guardian.new(moderator).can_recover_topic?(topic.reload)).to be_falsey
|
||||
expect(Guardian.new(moderator).can_recover_topic?(topic.reload)).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1199,7 +1199,7 @@ describe Guardian do
|
||||
PostDestroyer.new(moderator, post).destroy
|
||||
post.user.destroy!
|
||||
|
||||
expect(Guardian.new(moderator).can_recover_post?(post.reload)).to be_falsey
|
||||
expect(Guardian.new(moderator).can_recover_post?(post.reload)).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -180,6 +180,15 @@ describe PostDestroyer do
|
||||
expect(post_action).to be_present
|
||||
end
|
||||
|
||||
it "works with topics and posts with no user" do
|
||||
post = Fabricate(:post)
|
||||
UserDestroyer.new(Discourse.system_user).destroy(post.user, delete_posts: true)
|
||||
|
||||
expect { PostDestroyer.new(Fabricate(:admin), post.reload).recover }
|
||||
.to change { post.reload.user_id }.to(Discourse.system_user.id)
|
||||
.and change { post.topic.user_id }.to(Discourse.system_user.id)
|
||||
end
|
||||
|
||||
describe "post_count recovery" do
|
||||
before do
|
||||
post
|
||||
|
Reference in New Issue
Block a user