FIX: Avoid the deleted_at scope when recovering a topic from a recently recovered post

This commit is contained in:
Roman Rizzi 2019-03-29 10:36:29 -03:00 committed by Robin Ward
parent d26d1b387e
commit 7740b1570b
2 changed files with 12 additions and 1 deletions

View File

@ -85,7 +85,7 @@ class PostDestroyer
UserActionManager.post_created(@post) UserActionManager.post_created(@post)
DiscourseEvent.trigger(:post_recovered, @post, @opts, @user) DiscourseEvent.trigger(:post_recovered, @post, @opts, @user)
if @post.is_first_post? if @post.is_first_post?
UserActionManager.topic_created(@post.topic) UserActionManager.topic_created(topic)
DiscourseEvent.trigger(:topic_recovered, topic, @user) DiscourseEvent.trigger(:topic_recovered, topic, @user)
StaffActionLogger.new(@user).log_topic_delete_recover(topic, "recover_topic", @opts.slice(:context)) if @user.id != @post.user_id StaffActionLogger.new(@user).log_topic_delete_recover(topic, "recover_topic", @opts.slice(:context)) if @user.id != @post.user_id
end end

View File

@ -177,6 +177,17 @@ describe PostDestroyer do
expect(@user.user_stat.post_count).to eq(1) expect(@user.user_stat.post_count).to eq(1)
end end
it 'Recovers the post correctly' do
PostDestroyer.new(admin, post).destroy
post.reload
PostDestroyer.new(admin, post).recover
recovered_topic = post.reload.topic
expect(recovered_topic.deleted_at).to be_nil
expect(recovered_topic.deleted_by_id).to be_nil
end
context "recovered by user" do context "recovered by user" do
it "should increment the user's post count" do it "should increment the user's post count" do
PostDestroyer.new(@user, @reply).destroy PostDestroyer.new(@user, @reply).destroy