mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:21:18 +08:00
FEATURE: Ability to clear a user's penalty history
You can do this manually if you want to allow them to reach TL3 without their penalty history counting against them.
This commit is contained in:
@ -47,4 +47,42 @@ RSpec.describe Admin::UsersController do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#penalty_history" do
|
||||
let(:moderator) { Fabricate(:moderator) }
|
||||
let(:logger) { StaffActionLogger.new(admin) }
|
||||
|
||||
it "doesn't allow moderators to clear a user's history" do
|
||||
sign_in(moderator)
|
||||
delete "/admin/users/#{user.id}/penalty_history.json"
|
||||
expect(response.code).to eq("404")
|
||||
end
|
||||
|
||||
def find_logs(action)
|
||||
UserHistory.where(target_user_id: user.id, action: UserHistory.actions[action])
|
||||
end
|
||||
|
||||
it "allows admins to clear a user's history" do
|
||||
logger.log_user_suspend(user, "suspend reason")
|
||||
logger.log_user_unsuspend(user)
|
||||
logger.log_unsilence_user(user)
|
||||
logger.log_silence_user(user)
|
||||
|
||||
sign_in(admin)
|
||||
delete "/admin/users/#{user.id}/penalty_history.json"
|
||||
expect(response.code).to eq("200")
|
||||
|
||||
expect(find_logs(:suspend_user)).to be_blank
|
||||
expect(find_logs(:unsuspend_user)).to be_blank
|
||||
expect(find_logs(:silence_user)).to be_blank
|
||||
expect(find_logs(:unsilence_user)).to be_blank
|
||||
|
||||
expect(find_logs(:removed_suspend_user)).to be_present
|
||||
expect(find_logs(:removed_unsuspend_user)).to be_present
|
||||
expect(find_logs(:removed_silence_user)).to be_present
|
||||
expect(find_logs(:removed_unsilence_user)).to be_present
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user