Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-06-12 12:50:39 +0300
committerRémy Coutable <remy@rymai.me>2017-06-12 12:50:39 +0300
commit1feb0894f73142c0127db86a3a84833d501e474f (patch)
tree8a3839cbc6d7000221fe81e4c5670d3d271dc2fd
parent194c40df208526d5dc4401bc06f91d803def3740 (diff)
parent4ccd79983274442ca21e6c73ef0863097b57350c (diff)
Merge branch '33003-avatar-in-project-api' into 'master'
Accept avatar file in project API Closes #33003 See merge request !11988
-rw-r--r--changelogs/unreleased/33003-avatar-in-project-api.yml4
-rw-r--r--doc/api/projects.md3
-rw-r--r--lib/api/projects.rb1
-rw-r--r--spec/requests/api/projects_spec.rb9
4 files changed, 17 insertions, 0 deletions
diff --git a/changelogs/unreleased/33003-avatar-in-project-api.yml b/changelogs/unreleased/33003-avatar-in-project-api.yml
new file mode 100644
index 00000000000..41d796ebb32
--- /dev/null
+++ b/changelogs/unreleased/33003-avatar-in-project-api.yml
@@ -0,0 +1,4 @@
+---
+title: Accept image for avatar in project API
+merge_request: 11988
+author: Ivan Chernov
diff --git a/doc/api/projects.md b/doc/api/projects.md
index 716486022b0..58f18105e21 100644
--- a/doc/api/projects.md
+++ b/doc/api/projects.md
@@ -343,6 +343,7 @@ Parameters:
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
| `tag_list` | array | no | The list of tags for a project; put array of tags, that should be finally assigned to a project |
+| `avatar` | mixed | no | Image file for avatar of the project |
### Create project for user
@@ -377,6 +378,7 @@ Parameters:
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
| `tag_list` | array | no | The list of tags for a project; put array of tags, that should be finally assigned to a project |
+| `avatar` | mixed | no | Image file for avatar of the project |
### Edit project
@@ -410,6 +412,7 @@ Parameters:
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
| `tag_list` | array | no | The list of tags for a project; put array of tags, that should be finally assigned to a project |
+| `avatar` | mixed | no | Image file for avatar of the project |
### Fork project
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 56046742e08..50d34e8a738 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -22,6 +22,7 @@ module API
optional :only_allow_merge_if_pipeline_succeeds, type: Boolean, desc: 'Only allow to merge if builds succeed'
optional :only_allow_merge_if_all_discussions_are_resolved, type: Boolean, desc: 'Only allow to merge if all discussions are resolved'
optional :tag_list, type: Array[String], desc: 'The list of tags for a project'
+ optional :avatar, type: File, desc: 'Avatar image for project'
end
params :optional_params do
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 86c57204971..3e831373514 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -398,6 +398,15 @@ describe API::Projects do
expect(json_response['tag_list']).to eq(%w[tagFirst tagSecond])
end
+ it 'uploads avatar for project a project' do
+ project = attributes_for(:project, avatar: fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif'))
+
+ post api('/projects', user), project
+
+ project_id = json_response['id']
+ expect(json_response['avatar_url']).to eq("http://localhost/uploads/system/project/avatar/#{project_id}/banana_sample.gif")
+ end
+
it 'sets a project as allowing merge even if build fails' do
project = attributes_for(:project, { only_allow_merge_if_pipeline_succeeds: false })
post api('/projects', user), project