Commit 8dc2fdb2 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'kassio/group-avatar-api-remote-file-name' into 'master'

Group Avatar API: ensure to send the remote filename

See merge request gitlab-org/gitlab!64650
parents 14f00cbb 7edcf42a
......@@ -14,6 +14,20 @@ module API
detail 'This feature was introduced in GitLab 14.0'
end
get ':id/avatar' do
avatar = user_group.avatar
not_found!('Avatar') if avatar.blank?
filename = File.basename(avatar.file.file)
header(
'Content-Disposition',
ActionDispatch::Http::ContentDisposition.format(
disposition: 'attachment',
filename: filename
)
)
present_carrierwave_file!(user_group.avatar)
end
end
......
......@@ -15,6 +15,8 @@ RSpec.describe API::GroupAvatar do
get api(avatar_path(group))
expect(response).to have_gitlab_http_status(:ok)
expect(response.headers['Content-Disposition'])
.to eq(%(attachment; filename="dk.png"; filename*=UTF-8''dk.png))
end
context 'when the group does not have avatar' do
......@@ -24,6 +26,8 @@ RSpec.describe API::GroupAvatar do
get api(avatar_path(group))
expect(response).to have_gitlab_http_status(:not_found)
expect(response.body)
.to eq(%({"message":"404 Avatar Not Found"}))
end
end
......
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