diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-06-01 10:52:19 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-06-01 17:34:48 +0300 |
commit | 6185d12c183b539ea06ab3550b2c21045d169ca4 (patch) | |
tree | 9a5a8e50f8b0c6c64d69099d0374dc15ace808ee /spec | |
parent | e61f38d79eb85a7c601bd146d5b8e48a8b4418e5 (diff) |
Add missing specs
Diffstat (limited to 'spec')
-rw-r--r-- | spec/migrations/migrate_old_artifacts_spec.rb | 16 | ||||
-rw-r--r-- | spec/uploaders/artifact_uploader_spec.rb | 38 | ||||
-rw-r--r-- | spec/uploaders/gitlab_uploader_spec.rb | 56 |
3 files changed, 102 insertions, 8 deletions
diff --git a/spec/migrations/migrate_old_artifacts_spec.rb b/spec/migrations/migrate_old_artifacts_spec.rb index 9d951038dcc..50f4bbda001 100644 --- a/spec/migrations/migrate_old_artifacts_spec.rb +++ b/spec/migrations/migrate_old_artifacts_spec.rb @@ -93,17 +93,17 @@ describe MigrateOldArtifacts do FileUtils.mkdir_p(legacy_path(build)) FileUtils.copy( - Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), - File.join(legacy_path(build), "ci_build_artifacts.zip") - ) + Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), + File.join(legacy_path(build), "ci_build_artifacts.zip")) + FileUtils.copy( - Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'), - File.join(legacy_path(build), "ci_build_artifacts_metadata.gz") - ) + Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'), + File.join(legacy_path(build), "ci_build_artifacts_metadata.gz")) + build.update_columns( artifacts_file: 'ci_build_artifacts.zip', - artifacts_metadata: 'ci_build_artifacts_metadata.gz', - ) + artifacts_metadata: 'ci_build_artifacts_metadata.gz') + build.reload end diff --git a/spec/uploaders/artifact_uploader_spec.rb b/spec/uploaders/artifact_uploader_spec.rb new file mode 100644 index 00000000000..24e2e3a9f0e --- /dev/null +++ b/spec/uploaders/artifact_uploader_spec.rb @@ -0,0 +1,38 @@ +require 'rails_helper' + +describe ArtifactUploader do + let(:job) { create(:ci_build) } + let(:uploader) { described_class.new(job, :artifacts_file) } + let(:path) { Gitlab.config.artifacts.path } + + describe '.local_artifacts_store' do + subject { described_class.local_artifacts_store } + + it "delegate to artifacts path" do + expect(Gitlab.config.artifacts).to receive(:path) + + subject + end + end + + describe '.artifacts_upload_path' do + subject { described_class.artifacts_upload_path } + + it { is_expected.to start_with(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}") } + end + + describe '#cache_dir' do + subject { uploader.cache_dir } + + it { is_expected.to start_with(path) } + it { is_expected.to end_with('tmp/cache') } + end +end diff --git a/spec/uploaders/gitlab_uploader_spec.rb b/spec/uploaders/gitlab_uploader_spec.rb new file mode 100644 index 00000000000..78e9d9cf46c --- /dev/null +++ b/spec/uploaders/gitlab_uploader_spec.rb @@ -0,0 +1,56 @@ +require 'rails_helper' +require 'carrierwave/storage/fog' + +describe GitlabUploader do + let(:uploader_class) { Class.new(described_class) } + + subject { uploader_class.new } + + describe '#file_storage?' do + context 'when file storage is used' do + before do + uploader_class.storage(:file) + end + + it { is_expected.to be_file_storage } + end + + context 'when is remote storage' do + before do + uploader_class.storage(:fog) + end + + it { is_expected.not_to be_file_storage } + end + end + + describe '#file_cache_storage?' do + context 'when file storage is used' do + before do + uploader_class.cache_storage(:file) + end + + it { is_expected.to be_file_cache_storage } + end + + context 'when is remote storage' do + before do + uploader_class.cache_storage(:fog) + end + + it { is_expected.not_to be_file_cache_storage } + end + end + + describe '#move_to_cache' do + it 'is true' do + expect(subject.move_to_cache).to eq(true) + end + end + + describe '#move_to_store' do + it 'is true' do + expect(subject.move_to_store).to eq(true) + end + end +end |