Commit 2923a0c8 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '26212-upload-user-avatar-trough-api' into 'master'

Accept image for avatar in user API

Closes #26212

See merge request !12143
parents a4a5cbf2 83a9a472
---
title: Accept image for avatar in user API
merge_request: 12143
author: Ivan Chernov
...@@ -251,6 +251,7 @@ Parameters: ...@@ -251,6 +251,7 @@ Parameters:
- `can_create_group` (optional) - User can create groups - true or false - `can_create_group` (optional) - User can create groups - true or false
- `confirm` (optional) - Require confirmation - true (default) or false - `confirm` (optional) - Require confirmation - true (default) or false
- `external` (optional) - Flags the user as external - true or false(default) - `external` (optional) - Flags the user as external - true or false(default)
- `avatar` (optional) - Image file for user's avatar
## User modification ## User modification
...@@ -279,6 +280,7 @@ Parameters: ...@@ -279,6 +280,7 @@ Parameters:
- `admin` (optional) - User is admin - true or false (default) - `admin` (optional) - User is admin - true or false (default)
- `can_create_group` (optional) - User can create groups - true or false - `can_create_group` (optional) - User can create groups - true or false
- `external` (optional) - Flags the user as external - true or false(default) - `external` (optional) - Flags the user as external - true or false(default)
- `avatar` (optional) - Image file for user's avatar
On password update, user will be forced to change it upon next login. On password update, user will be forced to change it upon next login.
Note, at the moment this method does only return a `404` error, Note, at the moment this method does only return a `404` error,
......
...@@ -29,6 +29,7 @@ module API ...@@ -29,6 +29,7 @@ module API
optional :can_create_group, type: Boolean, desc: 'Flag indicating the user can create groups' optional :can_create_group, type: Boolean, desc: 'Flag indicating the user can create groups'
optional :skip_confirmation, type: Boolean, default: false, desc: 'Flag indicating the account is confirmed' optional :skip_confirmation, type: Boolean, default: false, desc: 'Flag indicating the account is confirmed'
optional :external, type: Boolean, desc: 'Flag indicating the user is an external user' optional :external, type: Boolean, desc: 'Flag indicating the user is an external user'
optional :avatar, type: File, desc: 'Avatar image for user'
all_or_none_of :extern_uid, :provider all_or_none_of :extern_uid, :provider
end end
end end
......
...@@ -377,6 +377,16 @@ describe API::Users do ...@@ -377,6 +377,16 @@ describe API::Users do
expect(user.reload.organization).to eq('GitLab') expect(user.reload.organization).to eq('GitLab')
end end
it 'updates user with avatar' do
put api("/users/#{user.id}", admin), { avatar: fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif') }
user.reload
expect(user.avatar).to be_present
expect(response).to have_http_status(200)
expect(json_response['avatar_url']).to include(user.avatar_path)
end
it 'updates user with his own email' do it 'updates user with his own email' do
put api("/users/#{user.id}", admin), email: user.email put api("/users/#{user.id}", admin), email: user.email
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment