Commit 826ef4f2 authored by charlie ablett's avatar charlie ablett

Merge branch 'kassio/fix-subgroup-avatar-api' into 'master'

Fix group avatar API endpoint to work with subgroups

See merge request gitlab-org/gitlab!63934
parents 7ef56140 f8573b56
......@@ -6,13 +6,13 @@ module API
feature_category :subgroups
resource :groups do
params do
requires :id, type: String, desc: 'The ID of a group'
end
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Download the group avatar' do
detail 'This feature was introduced in GitLab 14.0'
end
params do
requires :id, type: String, desc: 'The group id'
end
get ':id/avatar' do
present_carrierwave_file!(user_group.avatar)
end
......
......@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe API::GroupAvatar do
def avatar_path(group)
"/groups/#{group.id}/avatar"
"/groups/#{ERB::Util.url_encode(group.full_path)}/avatar"
end
describe 'GET /groups/:id/avatar' do
......@@ -26,6 +26,16 @@ RSpec.describe API::GroupAvatar do
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when the group is a subgroup' do
it 'returns :ok' do
group = create(:group, :nested, :public, :with_avatar, name: 'g1.1')
get api(avatar_path(group))
expect(response).to have_gitlab_http_status(:ok)
end
end
end
context 'when the group is private' do
......
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