FEATURE: show post approvals in Moderation History (#6643)

FEATURE: show post approvals in Moderation History (#6643)

From 8e32aa1483987963630140f306ce413c9cbc0de3 Mon Sep 17 00:00:00 2001
From: Kyle Zhao <kzhao.sw@gmail.com>
Date: Wed, 21 Nov 2018 21:22:23 -0500
Subject: [PATCH] FEATURE: show post approvals in Moderation History (#6643)


diff --git a/app/controllers/admin/moderation_history_controller.rb b/app/controllers/admin/moderation_history_controller.rb
index 5bad39a..d5516dd 100644
--- a/app/controllers/admin/moderation_history_controller.rb
+++ b/app/controllers/admin/moderation_history_controller.rb
@@ -10,7 +10,8 @@ class Admin::ModerationHistoryController < Admin::AdminController
         :suspend_user,
         :silence_user,
         :delete_post,
-        :delete_topic
+        :delete_topic,
+        :post_approved,
       ).values
     )
 
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 720076e..7ec9c4f 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -3475,6 +3475,7 @@ en:
           silence_user: "User Silenced"
           delete_post: "Post Deleted"
           delete_topic: "Topic Deleted"
+          post_approved: "Post Approved"
 
       logs:
         title: "Logs"
diff --git a/spec/requests/admin/moderation_history_controller_spec.rb b/spec/requests/admin/moderation_history_controller_spec.rb
index b35989a..866664c 100644
--- a/spec/requests/admin/moderation_history_controller_spec.rb
+++ b/spec/requests/admin/moderation_history_controller_spec.rb
@@ -35,6 +35,17 @@ RSpec.describe Admin::BackupsController do
       expect(::JSON.parse(response.body)['moderation_history']).to be_present
     end
 
+    it 'includes post approval record' do
+      queued_post = Fabricate(:queued_post)
+      post = queued_post.approve!(Discourse.system_user)
+
+      get "/admin/moderation_history.json?filter=post&post_id=#{post.id}"
+
+      expect(response.status).to eq(200)
+
+      moderation_history = JSON.parse(response.body)['moderation_history'].first
+      expect(moderation_history['action_name']).to eq('post_approved')
+    end
   end
 
   describe "for a topic" do

GitHub

1 Like