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