mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FEATURE: Show a button to Staff for "Moderation History" on posts/topics
When clicked, it pops up a modal showing a history of moderation actions taken on the post or topic.
This commit is contained in:
parent
85a59c632d
commit
410994b7f5
20 changed files with 244 additions and 7 deletions
55
spec/requests/admin/moderation_history_controller_spec.rb
Normal file
55
spec/requests/admin/moderation_history_controller_spec.rb
Normal file
|
@ -0,0 +1,55 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::BackupsController do
|
||||
let(:admin) { Fabricate(:admin) }
|
||||
|
||||
before do
|
||||
sign_in(admin)
|
||||
end
|
||||
|
||||
describe "parameters" do
|
||||
it "returns 404 without a valid filter" do
|
||||
get "/admin/moderation_history.json"
|
||||
expect(response).not_to be_success
|
||||
end
|
||||
|
||||
it "returns 404 without a valid id" do
|
||||
get "/admin/moderation_history.json?filter=topic"
|
||||
expect(response).not_to be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe "for a post" do
|
||||
it "returns an empty array when the post doesn't exist" do
|
||||
get "/admin/moderation_history.json?filter=post&post_id=99999999"
|
||||
expect(response).to be_success
|
||||
expect(::JSON.parse(response.body)['moderation_history']).to be_blank
|
||||
end
|
||||
|
||||
it "returns a history when the post exists" do
|
||||
p = Fabricate(:post)
|
||||
p = Fabricate(:post, topic_id: p.topic_id)
|
||||
PostDestroyer.new(Discourse.system_user, p).destroy
|
||||
get "/admin/moderation_history.json?filter=post&post_id=#{p.id}"
|
||||
expect(response).to be_success
|
||||
expect(::JSON.parse(response.body)['moderation_history']).to be_present
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "for a topic" do
|
||||
it "returns empty history when the topic doesn't exist" do
|
||||
get "/admin/moderation_history.json?filter=topic&topic_id=1234"
|
||||
expect(response).to be_success
|
||||
expect(::JSON.parse(response.body)['moderation_history']).to be_blank
|
||||
end
|
||||
|
||||
it "returns a history when the topic exists" do
|
||||
p = Fabricate(:post)
|
||||
PostDestroyer.new(Discourse.system_user, p).destroy
|
||||
get "/admin/moderation_history.json?filter=topic&topic_id=#{p.topic_id}"
|
||||
expect(response).to be_success
|
||||
expect(::JSON.parse(response.body)['moderation_history']).to be_present
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue