diff --git a/spec/requests/api/artifacts_spec.rb b/spec/requests/api/artifacts_spec.rb deleted file mode 100644 index 56d0965b0be72814c57c5d927e7e3e37b01e9d77..0000000000000000000000000000000000000000 --- a/spec/requests/api/artifacts_spec.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'spec_helper' -require_relative '../shared/artifacts_context' - -describe API::API, api: true do - include ApiHelpers - - describe 'GET /projects/:id/artifacts/:ref_name/:build_name' do - include_context 'artifacts from ref and build name' - - def path_from_ref(ref = pipeline.sha, job = build.name) - api("/projects/#{project.id}/builds/artifacts/#{ref}?job=#{job}", user) - end - - context '401' do - let(:user) { nil } - - before do - get path_from_ref - end - - it 'gives 401 for unauthorized user' do - expect(response).to have_http_status(401) - end - end - - context '404' do - def verify - expect(response).to have_http_status(404) - end - - it_behaves_like 'artifacts from ref with 404' - end - - context '200' do - def verify - 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' - end - end -end diff --git a/spec/requests/api/builds_spec.rb b/spec/requests/api/builds_spec.rb index 350d9cb5c7edee35fa8b46bdaed4270aeb20b493..5d2e2293236c14018c3526f609741034e2193671 100644 --- a/spec/requests/api/builds_spec.rb +++ b/spec/requests/api/builds_spec.rb @@ -1,4 +1,5 @@ require 'spec_helper' +require_relative '../shared/artifacts_context' describe API::API, api: true do include ApiHelpers @@ -186,6 +187,48 @@ describe API::API, api: true do end end + describe 'GET /projects/:id/artifacts/:ref_name/:build_name' do + include_context 'artifacts from ref and build name' + + def path_from_ref(ref = pipeline.sha, job = build.name) + api("/projects/#{project.id}/builds/artifacts/#{ref}?job=#{job}", user) + end + + context '401' do + let(:user) { nil } + + before do + get path_from_ref + end + + it 'gives 401 for unauthorized user' do + expect(response).to have_http_status(401) + end + end + + context '404' do + def verify + expect(response).to have_http_status(404) + end + + it_behaves_like 'artifacts from ref with 404' + end + + context '200' do + def verify + 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' + end + end + describe 'GET /projects/:id/builds/:build_id/trace' do let(:build) { create(:ci_build, :trace, pipeline: pipeline) }