Commit cf0a61c2 authored by Jasper Maes's avatar Jasper Maes

Rails5: fix artifacts controller download spec

Rails5 has params[:file_type] as '' if file_type is included as nil
in the request
parent d031e0e8
---
title: 'Rails5: fix artifacts controller download spec Rails5 has params[:file_type]
as '''' if file_type is included as nil in the request'
merge_request: 22123
author: Jasper Maes
type: other
...@@ -19,15 +19,17 @@ describe Projects::ArtifactsController do ...@@ -19,15 +19,17 @@ describe Projects::ArtifactsController do
end end
describe 'GET download' do describe 'GET download' do
subject { get :download, namespace_id: project.namespace, project_id: project, job_id: job, file_type: file_type } def download_artifact(extra_params = {})
params = { namespace_id: project.namespace, project_id: project, job_id: job }.merge(extra_params)
context 'when no file type is supplied' do get :download, params
let(:file_type) { nil } end
context 'when no file type is supplied' do
it 'sends the artifacts file' 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 expect(controller).to receive(:send_file).with(job.artifacts_file.path, hash_including(disposition: 'attachment')).and_call_original
subject download_artifact
end end
end end
...@@ -36,7 +38,7 @@ describe Projects::ArtifactsController do ...@@ -36,7 +38,7 @@ describe Projects::ArtifactsController do
let(:file_type) { 'invalid' } let(:file_type) { 'invalid' }
it 'returns 404' do it 'returns 404' do
subject download_artifact(file_type: file_type)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(404)
end end
...@@ -52,7 +54,7 @@ describe Projects::ArtifactsController do ...@@ -52,7 +54,7 @@ describe Projects::ArtifactsController do
it 'sends the codequality report' do 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 expect(controller).to receive(:send_file).with(job.job_artifacts_codequality.file.path, hash_including(disposition: 'attachment')).and_call_original
subject download_artifact(file_type: file_type)
end end
end end
end end
......
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