diff options
author | Micaël Bergeron <mbergeron@gitlab.com> | 2018-03-07 13:27:49 -0500 |
---|---|---|
committer | Micaël Bergeron <mbergeron@gitlab.com> | 2018-03-07 13:27:49 -0500 |
commit | 2bf29a0c81a9adaf464174635159d4e65f30c7a2 (patch) | |
tree | 5b58eb3f567470901b2c79a79afd1859b3f06ffd | |
parent | a85948862ebadb02dbe93d5ce74ba00f32d9a0c0 (diff) | |
download | gitlab-ce-2bf29a0c81a9adaf464174635159d4e65f30c7a2.tar.gz |
fix yet other specs
-rw-r--r-- | spec/models/ci/build_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/ci/job_artifact_spec.rb | 4 | ||||
-rw-r--r-- | spec/requests/api/jobs_spec.rb | 44 |
3 files changed, 30 insertions, 22 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 74930a8d59c..b28baa4a442 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -210,13 +210,13 @@ describe Ci::Build do subject { build.downloadable_single_artifacts_file? } context 'artifacts are stored locally' do - let(:store) { ObjectStoreUploader::LOCAL_STORE } + let(:store) { ObjectStorage::Store::LOCAL } it { is_expected.to be_truthy } end context 'artifacts are stored remotely' do - let(:store) { ObjectStoreUploader::REMOTE_STORE } + let(:store) { ObjectStorage::Store::REMOTE } before do stub_artifacts_object_storage diff --git a/spec/models/ci/job_artifact_spec.rb b/spec/models/ci/job_artifact_spec.rb index 730b7691279..1aa28434879 100644 --- a/spec/models/ci/job_artifact_spec.rb +++ b/spec/models/ci/job_artifact_spec.rb @@ -38,7 +38,7 @@ describe Ci::JobArtifact do end it 'schedules the model for migration' do - expect(ObjectStorageUploadWorker).to receive(:perform_async).with('JobArtifactUploader', described_class.name, :file, kind_of(Numeric)) + expect(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async).with('JobArtifactUploader', described_class.name, :file, kind_of(Numeric)) subject end @@ -50,7 +50,7 @@ describe Ci::JobArtifact do end it 'schedules the model for migration' do - expect(ObjectStorageUploadWorker).not_to receive(:perform_async) + expect(ObjectStorage::BackgroundMoveWorker).not_to receive(:perform_async) subject end diff --git a/spec/requests/api/jobs_spec.rb b/spec/requests/api/jobs_spec.rb index ae0c377682e..62ed9fd00a1 100644 --- a/spec/requests/api/jobs_spec.rb +++ b/spec/requests/api/jobs_spec.rb @@ -19,12 +19,8 @@ describe API::Jobs do let(:api_user) { user } let(:reporter) { create(:project_member, :reporter, project: project).user } let(:guest) { create(:project_member, :guest, project: project).user } - let(:cross_project_pipeline_enabled) { true } - let(:object_storage_enabled) { true } before do - stub_licensed_features(cross_project_pipelines: cross_project_pipeline_enabled, - object_storage: object_storage_enabled) project.add_developer(user) end @@ -326,10 +322,6 @@ describe API::Jobs do end context 'normal authentication' do - before do - stub_artifacts_object_storage - end - context 'job with artifacts' do context 'when artifacts are stored locally' do let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) } @@ -342,14 +334,20 @@ describe API::Jobs do it_behaves_like 'downloads artifact' end - it 'returns specific job artifacts' do - expect(response).to have_http_status(200) - expect(response.headers).to include(download_headers) - expect(response.body).to match_file(job.artifacts_file.file.file) + context 'unauthorized user' do + let(:api_user) { nil } + + it 'does not return specific job artifacts' do + expect(response).to have_gitlab_http_status(404) + end end end context 'when artifacts are stored remotely' do + before do + stub_artifacts_object_storage + end + let(:job) { create(:ci_build, pipeline: pipeline) } let!(:artifact) { create(:ci_job_artifact, :archive, :remote_store, job: job) } @@ -359,15 +357,25 @@ describe API::Jobs do get api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user) end - it 'does not return specific job artifacts' do - expect(response).to have_http_status(401) + context 'authorized user' do + it 'returns the file remote URL' do + expect(response).to redirect_to(artifact.file.url) + end + end + + context 'unauthorized user' do + let(:api_user) { nil } + + it 'does not return specific job artifacts' do + expect(response).to have_gitlab_http_status(404) + end end end it 'does not return job artifacts if not uploaded' do get api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -378,7 +386,7 @@ describe API::Jobs do let(:job) { create(:ci_build, :artifacts, pipeline: pipeline, user: api_user) } before do - stub_artifacts_object_storage(licensed: :skip) + stub_artifacts_object_storage job.success end @@ -442,7 +450,7 @@ describe API::Jobs do "attachment; filename=#{job.artifacts_file.filename}" } end - it { expect(response).to have_http_status(200) } + it { expect(response).to have_http_status(:ok) } it { expect(response.headers).to include(download_headers) } end @@ -457,7 +465,7 @@ describe API::Jobs do end it 'returns location redirect' do - expect(response).to have_http_status(302) + expect(response).to have_http_status(:found) end end end |