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:
Robin Ward
2018-05-25 11:45:42 -04:00
parent c658fb6e31
commit 4195c7c9ea
7 changed files with 120 additions and 0 deletions

View File

@ -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