Commit c4496de8 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Provide the file directly rather than redirecting

parent 70f508f5
......@@ -69,9 +69,8 @@ module API
authorize_read_builds!
build = get_build!(params[:build_id])
artifacts_file = build.artifacts_file
present_artifact!(artifacts_file)
present_artifact!(build.artifacts_file)
end
# Download the artifacts file from ref_name and build_name
......@@ -90,8 +89,7 @@ module API
latest_build = builds.success.latest.first
if latest_build
redirect(
"/projects/#{user_project.id}/builds/#{latest_build.id}/artifacts")
present_artifact!(latest_build.artifacts_file)
else
not_found!
end
......
......@@ -31,10 +31,15 @@ describe API::API, api: true do
it_behaves_like 'artifacts from ref with 404'
end
context '302' do
context '200' do
def verify
expect(response).to redirect_to(
"/projects/#{project.id}/builds/#{build.id}/artifacts")
download_headers =
{ 'Content-Transfer-Encoding' => 'binary',
'Content-Disposition' =>
"attachment; filename=#{build.artifacts_file.filename}" }
expect(response).to have_http_status(200)
expect(response.headers).to include(download_headers)
end
it_behaves_like 'artifacts from ref with 302'
......
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