Commit 8e011e66 authored by Jaime Martinez's avatar Jaime Martinez

Fix return codes for getting an inexisting release

Updates the returned status codes for getting a release by tag name when
it does not exists.

Fixes https://gitlab.com/gitlab-org/gitlab/-/issues/216342

Changelog: fixed
parent 7771b31b
......@@ -60,6 +60,8 @@ module API
desc: 'If `true`, a response includes HTML rendered markdown of the release description.'
end
get ':id/releases/:tag_name', requirements: RELEASE_ENDPOINT_REQUIREMENTS do
not_found! unless release
authorize_download_code!
present release, with: Entities::Release, current_user: current_user, include_html_description: params[:include_html_description]
......
......@@ -463,10 +463,23 @@ RSpec.describe API::Releases do
end
context 'when specified tag is not found in the project' do
it 'cannot find the release entry' do
it 'returns 404 for maintater' do
get api("/projects/#{project.id}/releases/non_exist_tag", maintainer)
expect(response).to have_gitlab_http_status(:forbidden)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns project not found for no user' do
get api("/projects/#{project.id}/releases/non_exist_tag", nil)
expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Project Not Found')
end
it 'returns 404 for guest' do
get api("/projects/#{project.id}/releases/non_exist_tag", guest)
expect(response).to have_gitlab_http_status(: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