From 38d407d7a7fd07888cbfda26360cd0a1c4972ec5 Mon Sep 17 00:00:00 2001 From: Jamie Schembri Date: Mon, 9 Jul 2018 17:44:09 +0200 Subject: Fix #48537 - Update avatar only via the projects API --- changelogs/unreleased/48537-update-avatar-only-via-api.yml | 5 +++++ lib/api/projects.rb | 3 ++- spec/requests/api/projects_spec.rb | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/48537-update-avatar-only-via-api.yml diff --git a/changelogs/unreleased/48537-update-avatar-only-via-api.yml b/changelogs/unreleased/48537-update-avatar-only-via-api.yml new file mode 100644 index 00000000000..9b3ab946cc1 --- /dev/null +++ b/changelogs/unreleased/48537-update-avatar-only-via-api.yml @@ -0,0 +1,5 @@ +--- +title: Allow updating a project's avatar without other params +merge_request: +author: Jamie Schembri +type: fixed diff --git a/lib/api/projects.rb b/lib/api/projects.rb index b83da00502d..8273abe48c9 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -260,7 +260,8 @@ module API :snippets_enabled, :tag_list, :visibility, - :wiki_enabled + :wiki_enabled, + :avatar ] optional :name, type: String, desc: 'The name of the project' optional :default_branch, type: String, desc: 'The default branch of the project' diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index de540ba7a10..15da81b57db 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -1526,6 +1526,20 @@ describe API::Projects do expect(response).to have_gitlab_http_status(400) end + + it 'updates avatar' do + project_param = { + avatar: fixture_file_upload('spec/fixtures/banana_sample.gif', + 'image/gif') + } + + put api("/projects/#{project3.id}", user), project_param + + expect(response).to have_gitlab_http_status(200) + expect(json_response['avatar_url']).to eq('http://localhost/uploads/'\ + '-/system/project/avatar/'\ + "#{project3.id}/banana_sample.gif") + end end context 'when authenticated as project master' do -- cgit v1.2.1