Commit 98adf69c authored by Rajendra Kadam's avatar Rajendra Kadam

Add support for avatar in group create and update API, add specs

parent 1c6e59fa
......@@ -11,6 +11,8 @@ module API
optional :visibility, type: String,
values: Gitlab::VisibilityLevel.string_values,
desc: 'The visibility of the group'
# TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab/issues/14960
optional :avatar, type: File, desc: 'Avatar image for the group' # rubocop:disable Scalability/FileUploads
optional :share_with_group_lock, type: Boolean, desc: 'Prevent sharing a project with another group within this group'
optional :require_two_factor_authentication, type: Boolean, desc: 'Require all users in this group to setup Two-factor authentication'
optional :two_factor_grace_period, type: Integer, desc: 'Time before Two-factor authentication is enforced'
......
......@@ -570,6 +570,19 @@ describe API::Groups do
expect(json_response['default_branch_protection']).to eq(::Gitlab::Access::MAINTAINER_PROJECT_ACCESS)
end
it 'updates avatar' do
group_param = {
avatar: fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif')
}
put api("/groups/#{group1.id}", user1), params: group_param
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['avatar_url']).to eq('http://localhost/uploads/'\
'-/system/group/avatar/'\
"#{group1.id}/banana_sample.gif")
end
it 'returns 404 for a non existing group' do
put api('/groups/1328', user1), params: { name: new_group_name }
......@@ -988,6 +1001,18 @@ describe API::Groups do
expect(json_response["visibility"]).to eq(Gitlab::VisibilityLevel.string_level(Gitlab::CurrentSettings.current_application_settings.default_group_visibility))
end
it "uploads avatar for a group" do
group = attributes_for_group_api request_access_enabled: false
group.merge!(avatar: fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif'))
post api("/groups", user3), params: group
group_id = json_response['id']
expect(json_response['avatar_url']).to eq('http://localhost/uploads/'\
'-/system/group/avatar/'\
"#{group_id}/banana_sample.gif")
end
it "creates a nested group" do
parent = create(:group)
parent.add_owner(user3)
......
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