FIX: Disagree and Restore should not revert edits

FIX: Disagree and Restore should not revert edits

diff --git a/app/models/reviewable_flagged_post.rb b/app/models/reviewable_flagged_post.rb
index 4b1acb0..67ae263 100644
--- a/app/models/reviewable_flagged_post.rb
+++ b/app/models/reviewable_flagged_post.rb
@@ -154,9 +154,7 @@ class ReviewableFlaggedPost < Reviewable
   end
 
   def perform_disagree_and_restore(performed_by, args)
-    result = perform_disagree(performed_by, args)
-    PostDestroyer.new(performed_by, post).recover
-    result
+    perform_disagree(performed_by, args)
   end
 
   def perform_disagree(performed_by, args)
diff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rb
index c30d7b5..cd53ab6 100644
--- a/lib/post_destroyer.rb
+++ b/lib/post_destroyer.rb
@@ -181,6 +181,8 @@ class PostDestroyer
   end
 
   def user_recovered
+    return unless @post.user_deleted?
+
     Post.transaction do
       @post.update_column(:user_deleted, false)
       @post.skip_unique_check = true
diff --git a/spec/components/post_destroyer_spec.rb b/spec/components/post_destroyer_spec.rb
index a5ac65e..6a88084 100644
--- a/spec/components/post_destroyer_spec.rb
+++ b/spec/components/post_destroyer_spec.rb
@@ -188,7 +188,7 @@ describe PostDestroyer do
         expect(recovered_topic.deleted_by_id).to be_nil
       end
 
-      context "recovered by user" do
+      context "recover" do
 
         it "doesn't raise an error when the raw doesn't change" do
           PostRevisor.new(@reply).revise!(
@@ -199,6 +199,16 @@ describe PostDestroyer do
           PostDestroyer.new(@user, @reply.reload).recover
         end
 
+        it "won't recover a non user-deleted post" do
+          PostRevisor.new(@reply).revise!(
+            admin,
+            { raw: 'this is a change to the post' },
+            force_new_version: true
+          )
+          PostDestroyer.new(@user, @reply.reload).recover
+          expect(@reply.reload.raw).to eq('this is a change to the post')
+        end
+
         it "should increment the user's post count" do
           PostDestroyer.new(@user, @reply).destroy
           expect(@user.user_stat.topic_count).to eq(1)
diff --git a/spec/models/reviewable_flagged_post_spec.rb b/spec/models/reviewable_flagged_post_spec.rb
index ab63024..956173e 100644
--- a/spec/models/reviewable_flagged_post_spec.rb
+++ b/spec/models/reviewable_flagged_post_spec.rb
@@ -173,6 +173,7 @@ RSpec.describe ReviewableFlaggedPost, type: :model do
       expect(reviewable).to be_rejected
       expect(score.reload).to be_disagreed
       expect(post.user_deleted?).to eq(false)
+      expect(post.hidden?).to eq(false)
     end
 
   end

GitHub sha: 6f7b6a33