FEATURE: Log when a group is deleted. (#11706)

We include the group "name" and "granted_trust_level" attributes.
This commit is contained in:
Roman Rizzi 2021-01-13 15:53:18 -03:00 committed by GitHub
parent bd7cbcd8f8
commit 1ad378f5c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 0 deletions

View File

@ -80,6 +80,10 @@ class Admin::GroupsController < Admin::AdminController
if group.automatic
can_not_modify_automatic
else
details = { name: group.name }
details[:grant_trust_level] = group.grant_trust_level if group.grant_trust_level
StaffActionLogger.new(current_user).log_custom('delete_group', details)
group.destroy!
render json: success_json
end

View File

@ -4437,6 +4437,7 @@ en:
topic_unarchived: "topic unarchived"
post_staff_note_create: "add staff note"
post_staff_note_destroy: "destroy staff note"
delete_group: "delete group"
screened_emails:
title: "Screened Emails"
description: "When someone tries to create a new account, the following email addresses will be checked and the registration will be blocked, or some other action performed."

View File

@ -235,6 +235,27 @@ RSpec.describe Admin::GroupsController do
expect(response.status).to eq(404)
end
it 'logs when a group is destroyed' do
delete "/admin/groups/#{group.id}.json"
history = UserHistory.where(acting_user: admin).last
expect(history).to be_present
expect(history.details).to include("name: #{group.name}")
end
it 'logs the grant_trust_level attribute' do
trust_level = TrustLevel[4]
group.update!(grant_trust_level: trust_level)
delete "/admin/groups/#{group.id}.json"
history = UserHistory.where(acting_user: admin).last
expect(history).to be_present
expect(history.details).to include("grant_trust_level: #{trust_level}")
expect(history.details).to include("name: #{group.name}")
end
describe 'when group is automatic' do
it "returns the right response" do
group.update!(automatic: true)