diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-10-02 17:01:26 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-10-02 17:01:26 +0000 |
commit | 48c911b75e96563991387dc1c7b3aaa071d511cc (patch) | |
tree | 922137e8f162cf74b3965fc39ac1913b1049f0f5 /spec/controllers/projects/artifacts_controller_spec.rb | |
parent | c0a982fad665e28769967b17eddd90900f62be78 (diff) | |
download | gitlab-ce-48c911b75e96563991387dc1c7b3aaa071d511cc.tar.gz |
CE Resolve "Refactor code quality similar to JUnit tests"
Diffstat (limited to 'spec/controllers/projects/artifacts_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/artifacts_controller_spec.rb | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/spec/controllers/projects/artifacts_controller_spec.rb b/spec/controllers/projects/artifacts_controller_spec.rb index 4ea6f869aa3..436f4525093 100644 --- a/spec/controllers/projects/artifacts_controller_spec.rb +++ b/spec/controllers/projects/artifacts_controller_spec.rb @@ -19,10 +19,42 @@ describe Projects::ArtifactsController do end describe 'GET download' do - it 'sends the artifacts file' do - expect(controller).to receive(:send_file).with(job.artifacts_file.path, hash_including(disposition: 'attachment')).and_call_original + subject { get :download, namespace_id: project.namespace, project_id: project, job_id: job, file_type: file_type } - get :download, namespace_id: project.namespace, project_id: project, job_id: job + context 'when no file type is supplied' do + let(:file_type) { nil } + + it 'sends the artifacts file' do + expect(controller).to receive(:send_file).with(job.artifacts_file.path, hash_including(disposition: 'attachment')).and_call_original + + subject + end + end + + context 'when a file type is supplied' do + context 'when an invalid file type is supplied' do + let(:file_type) { 'invalid' } + + it 'returns 404' do + subject + + expect(response).to have_gitlab_http_status(404) + end + end + + context 'when codequality file type is supplied' do + let(:file_type) { 'codequality' } + + before do + create(:ci_job_artifact, :codequality, job: job) + end + + it 'sends the codequality report' do + expect(controller).to receive(:send_file).with(job.job_artifacts_codequality.file.path, hash_including(disposition: 'attachment')).and_call_original + + subject + end + end end end |