Commit ddc47ed5 authored by Shinya Maeda's avatar Shinya Maeda

Merge branch '216342-fix-get-release-by-tag' into 'master'

Fix return codes for getting an inexistent release by tag

See merge request gitlab-org/gitlab!64591
parents 62939a50 360cd231
...@@ -62,6 +62,8 @@ module API ...@@ -62,6 +62,8 @@ module API
get ':id/releases/:tag_name', requirements: RELEASE_ENDPOINT_REQUIREMENTS do get ':id/releases/:tag_name', requirements: RELEASE_ENDPOINT_REQUIREMENTS do
authorize_download_code! authorize_download_code!
not_found! unless release
present release, with: Entities::Release, current_user: current_user, include_html_description: params[:include_html_description] present release, with: Entities::Release, current_user: current_user, include_html_description: params[:include_html_description]
end end
...@@ -177,7 +179,7 @@ module API ...@@ -177,7 +179,7 @@ module API
end end
def authorize_download_code! def authorize_download_code!
authorize! :download_code, release authorize! :download_code, user_project
end end
def authorize_create_evidence! def authorize_create_evidence!
......
...@@ -463,9 +463,23 @@ RSpec.describe API::Releases do ...@@ -463,9 +463,23 @@ RSpec.describe API::Releases do
end end
context 'when specified tag is not found in the project' do 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) get api("/projects/#{project.id}/releases/non_exist_tag", maintainer)
expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 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 forbidden for guest' do
get api("/projects/#{project.id}/releases/non_existing_tag", guest)
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:forbidden)
end end
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