Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-11-23 21:41:49 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2017-12-03 14:04:49 +0300
commitee8efb3d67ba8b8b2ece9962cd2aa79063fffaa0 (patch)
tree433dd5d93bc68ac1d7af5b4170333581fe7c91a3 /spec/uploaders
parent38c61ab6df15fbd1eab22a8dff8da01b17c075f3 (diff)
Sync ArtifactUploader specs with EE
Diffstat (limited to 'spec/uploaders')
-rw-r--r--spec/uploaders/job_artifact_uploader_spec.rb22
-rw-r--r--spec/uploaders/legacy_artifact_uploader_spec.rb28
2 files changed, 26 insertions, 24 deletions
diff --git a/spec/uploaders/job_artifact_uploader_spec.rb b/spec/uploaders/job_artifact_uploader_spec.rb
index bb2cc52381d..e80d5272a4a 100644
--- a/spec/uploaders/job_artifact_uploader_spec.rb
+++ b/spec/uploaders/job_artifact_uploader_spec.rb
@@ -1,33 +1,37 @@
require 'spec_helper'
describe JobArtifactUploader do
- set(:job_artifact) { create(:ci_job_artifact) }
+ let(:job_artifact) { create(:ci_job_artifact) }
let(:uploader) { described_class.new(job_artifact, :file) }
- let(:path) { Gitlab.config.artifacts.path }
+ let(:local_path) { Gitlab.config.artifacts.path }
describe '#store_dir' do
subject { uploader.store_dir }
- it { is_expected.to start_with(path) }
- it { is_expected.not_to end_with("#{job_artifact.project_id}/#{job_artifact.created_at.utc.strftime('%Y_%m')}/#{job_artifact.id}") }
- it { is_expected.to match(/\h{2}\/\h{2}\/\h{64}\/\d{4}_\d{1,2}_\d{1,2}\/\d+\/\d+\z/) }
+ let(:path) { "#{job_artifact.created_at.utc.strftime('%Y_%m_%d')}/#{job_artifact.project_id}/#{job_artifact.id}" }
+
+ context 'when using local storage' do
+ it { is_expected.to start_with(local_path) }
+ it { is_expected.to match(/\h{2}\/\h{2}\/\h{64}\/\d{4}_\d{1,2}_\d{1,2}\/\d+\/\d+\z/) }
+ it { is_expected.to end_with(path) }
+ end
end
describe '#cache_dir' do
subject { uploader.cache_dir }
- it { is_expected.to start_with(path) }
+ it { is_expected.to start_with(local_path) }
it { is_expected.to end_with('/tmp/cache') }
end
describe '#work_dir' do
subject { uploader.work_dir }
- it { is_expected.to start_with(path) }
+ it { is_expected.to start_with(local_path) }
it { is_expected.to end_with('/tmp/work') }
end
- context 'file is stored in valid path' do
+ context 'file is stored in valid local_path' do
let(:file) do
fixture_file_upload(Rails.root.join(
'spec/fixtures/ci_build_artifacts.zip'), 'application/zip')
@@ -39,7 +43,7 @@ describe JobArtifactUploader do
subject { uploader.file.path }
- it { is_expected.to start_with(path) }
+ it { is_expected.to start_with(local_path) }
it { is_expected.to include("/#{job_artifact.created_at.utc.strftime('%Y_%m_%d')}/") }
it { is_expected.to include("/#{job_artifact.project_id.to_s}/") }
it { is_expected.to end_with("ci_build_artifacts.zip") }
diff --git a/spec/uploaders/legacy_artifact_uploader_spec.rb b/spec/uploaders/legacy_artifact_uploader_spec.rb
index 203630de91c..714976b92c1 100644
--- a/spec/uploaders/legacy_artifact_uploader_spec.rb
+++ b/spec/uploaders/legacy_artifact_uploader_spec.rb
@@ -1,9 +1,9 @@
require 'rails_helper'
describe LegacyArtifactUploader do
- set(:job) { create(:ci_build) }
- let(:uploader) { described_class.new(job, :artifacts_file) }
- let(:path) { Gitlab.config.artifacts.path }
+ let(:job) { create(:ci_build) }
+ let(:uploader) { described_class.new(job, :legacy_artifacts_file) }
+ let(:local_path) { Gitlab.config.artifacts.path }
describe '.local_store_path' do
subject { described_class.local_store_path }
@@ -18,28 +18,32 @@ describe LegacyArtifactUploader do
describe '.artifacts_upload_path' do
subject { described_class.artifacts_upload_path }
- it { is_expected.to start_with(path) }
+ it { is_expected.to start_with(local_path) }
it { is_expected.to end_with('tmp/uploads/') }
end
describe '#store_dir' do
subject { uploader.store_dir }
- it { is_expected.to start_with(path) }
- it { is_expected.to end_with("#{job.project_id}/#{job.id}") }
+ let(:path) { "#{job.created_at.utc.strftime('%Y_%m')}/#{job.project_id}/#{job.id}" }
+
+ context 'when using local storage' do
+ it { is_expected.to start_with(local_path) }
+ it { is_expected.to end_with(path) }
+ end
end
describe '#cache_dir' do
subject { uploader.cache_dir }
- it { is_expected.to start_with(path) }
+ it { is_expected.to start_with(local_path) }
it { is_expected.to end_with('/tmp/cache') }
end
describe '#work_dir' do
subject { uploader.work_dir }
- it { is_expected.to start_with(path) }
+ it { is_expected.to start_with(local_path) }
it { is_expected.to end_with('/tmp/work') }
end
@@ -51,12 +55,6 @@ describe LegacyArtifactUploader do
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
context 'file is stored in valid path' do
@@ -71,7 +69,7 @@ describe LegacyArtifactUploader do
subject { uploader.file.path }
- it { is_expected.to start_with(path) }
+ it { is_expected.to start_with(local_path) }
it { is_expected.to include("/#{job.created_at.utc.strftime('%Y_%m')}/") }
it { is_expected.to include("/#{job.project_id.to_s}/") }
it { is_expected.to end_with("ci_build_artifacts.zip") }