mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:31:35 +08:00
FIX: Validate type when picking an avatar. (#11602)
This change improves the "UsersController#pick_avatar" validations to raise an error when "allow_uploaded_avatars" is disabled.
This commit is contained in:
@ -2309,6 +2309,29 @@ describe UsersController do
|
||||
expect(response.status).to eq(422)
|
||||
end
|
||||
|
||||
it 'ignores the upload if picking a system avatar' do
|
||||
SiteSetting.allow_uploaded_avatars = false
|
||||
another_upload = Fabricate(:upload)
|
||||
|
||||
put "/u/#{user.username}/preferences/avatar/pick.json", params: {
|
||||
upload_id: another_upload.id, type: "system"
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(user.reload.uploaded_avatar_id).to eq(nil)
|
||||
end
|
||||
|
||||
it 'raises an error if the type is invalid' do
|
||||
SiteSetting.allow_uploaded_avatars = false
|
||||
another_upload = Fabricate(:upload)
|
||||
|
||||
put "/u/#{user.username}/preferences/avatar/pick.json", params: {
|
||||
upload_id: another_upload.id, type: "x"
|
||||
}
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
end
|
||||
|
||||
it 'can successfully pick the system avatar' do
|
||||
put "/u/#{user.username}/preferences/avatar/pick.json"
|
||||
|
||||
|
Reference in New Issue
Block a user