summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2017-06-13 07:17:03 +0000
committerGrzegorz Bizon <grzegorz@gitlab.com>2017-06-13 07:17:03 +0000
commit6f5a68f528d6c11f3bfd013e30cc71845abe6ef8 (patch)
treea0aad9718961ac3a1b5b5f60be9935ca908edb48
parentde20057ccbd3b8c94d64ff5d8deb14cab232d08a (diff)
parent05683f313b40e1c37fbfbb04bd4d0e368dc5b39a (diff)
downloadgitlab-ce-6f5a68f528d6c11f3bfd013e30cc71845abe6ef8.tar.gz
Merge branch 'fix-filename-of-artifact-uploader' into 'master'
Fix filename method of GitlabUploader to return always real filename Closes #33524 See merge request !12113
-rw-r--r--app/uploaders/gitlab_uploader.rb4
-rw-r--r--spec/requests/api/runner_spec.rb25
-rw-r--r--spec/uploaders/artifact_uploader_spec.rb16
3 files changed, 43 insertions, 2 deletions
diff --git a/app/uploaders/gitlab_uploader.rb b/app/uploaders/gitlab_uploader.rb
index 136ec6cc6af..0da7a025591 100644
--- a/app/uploaders/gitlab_uploader.rb
+++ b/app/uploaders/gitlab_uploader.rb
@@ -61,6 +61,10 @@ class GitlabUploader < CarrierWave::Uploader::Base
CarrierWave.tmp_path
end
+ def filename
+ super || file&.filename
+ end
+
private
# To prevent files from moving across filesystems, override the default
diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb
index be83514ed9c..9556c99dea1 100644
--- a/spec/requests/api/runner_spec.rb
+++ b/spec/requests/api/runner_spec.rb
@@ -431,8 +431,29 @@ describe API::Runner do
expect(response).to have_http_status(201)
expect(json_response['id']).to eq(test_job.id)
expect(json_response['dependencies'].count).to eq(2)
- expect(json_response['dependencies']).to include({ 'id' => job.id, 'name' => job.name, 'token' => job.token },
- { 'id' => job2.id, 'name' => job2.name, 'token' => job2.token })
+ expect(json_response['dependencies']).to include(
+ { 'id' => job.id, 'name' => job.name, 'token' => job.token },
+ { 'id' => job2.id, 'name' => job2.name, 'token' => job2.token })
+ end
+ end
+
+ context 'when pipeline have jobs with artifacts' do
+ let!(:job) { create(:ci_build_tag, :artifacts, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) }
+ let!(:test_job) { create(:ci_build, pipeline: pipeline, name: 'deploy', stage: 'deploy', stage_idx: 1) }
+
+ before do
+ job.success
+ end
+
+ it 'returns dependent jobs' do
+ request_job
+
+ expect(response).to have_http_status(201)
+ expect(json_response['id']).to eq(test_job.id)
+ expect(json_response['dependencies'].count).to eq(1)
+ expect(json_response['dependencies']).to include(
+ { 'id' => job.id, 'name' => job.name, 'token' => job.token,
+ 'artifacts_file' => { 'filename' => 'ci_build_artifacts.zip', 'size' => 106365 } })
end
end
diff --git a/spec/uploaders/artifact_uploader_spec.rb b/spec/uploaders/artifact_uploader_spec.rb
index b3fac65c55e..2a3bd0e3bb2 100644
--- a/spec/uploaders/artifact_uploader_spec.rb
+++ b/spec/uploaders/artifact_uploader_spec.rb
@@ -42,4 +42,20 @@ describe ArtifactUploader do
it { is_expected.to start_with(path) }
it { is_expected.to end_with('/tmp/work') }
end
+
+ describe '#filename' do
+ # we need to use uploader, as this makes to use mounter
+ # which initialises uploader.file object
+ let(:uploader) { job.artifacts_file }
+
+ subject { uploader.filename }
+
+ it { is_expected.to be_nil }
+
+ context 'with artifacts' do
+ let(:job) { create(:ci_build, :artifacts) }
+
+ it { is_expected.not_to be_nil }
+ end
+ end
end