FIX: Remove user_deleted when staff recovers post (#10245)

This commit is contained in:
Mark VanLandingham 2020-07-16 09:15:01 -05:00 committed by GitHub
parent 3252cb847c
commit 62d5a9690f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -104,7 +104,9 @@ class PostDestroyer
end end
def staff_recovered def staff_recovered
@post.update_column(:user_id, Discourse::SYSTEM_USER_ID) if !@post.user_id new_post_attrs = { user_deleted: false }
new_post_attrs[:user_id] = Discourse::SYSTEM_USER_ID if !@post.user_id
@post.update_columns(new_post_attrs)
@post.recover! @post.recover!
mark_topic_changed mark_topic_changed

View File

@ -244,6 +244,14 @@ describe PostDestroyer do
end end
context "recovered by admin" do context "recovered by admin" do
it "should set user_deleted to false" do
PostDestroyer.new(@user, @reply).destroy
expect(@reply.reload.user_deleted).to eq(true)
PostDestroyer.new(admin, @reply).recover
expect(@reply.reload.user_deleted).to eq(false)
end
it "should increment the user's post count" do it "should increment the user's post count" do
PostDestroyer.new(moderator, @reply).destroy PostDestroyer.new(moderator, @reply).destroy
expect(@user.reload.user_stat.topic_count).to eq(1) expect(@user.reload.user_stat.topic_count).to eq(1)