FEATURE: Allow IP anonymization via admin user controller API (#11497)

* FEATURE: Allow IP anonymization via admin user controller API

Co-authored-by: Penar Musaraj <pmusaraj@gmail.com>
This commit is contained in:
Robin Ward
2020-12-15 15:48:16 -05:00
committed by GitHub
parent 8922a878f3
commit 745a5d84d2
2 changed files with 21 additions and 1 deletions

View File

@@ -1103,4 +1103,21 @@ RSpec.describe Admin::UsersController do
end
end
describe "#anonymize" do
it "will make the user anonymous" do
put "/admin/users/#{user.id}/anonymize.json"
expect(response.status).to eq(200)
expect(response.parsed_body['username']).to be_present
end
it "supports `anonymize_ip`" do
Jobs.run_immediately!
sl = Fabricate(:search_log, user_id: user.id)
put "/admin/users/#{user.id}/anonymize.json?anonymize_ip=127.0.0.2"
expect(response.status).to eq(200)
expect(response.parsed_body['username']).to be_present
expect(sl.reload.ip_address).to eq('127.0.0.2')
end
end
end