diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-21 21:08:57 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-21 21:08:57 +0000 |
commit | a6c2be7cd20a9515b347e72d63c5b47bb9b79457 (patch) | |
tree | 568212b4debeb2a35bb1133209b98e1468d9ee85 /spec/uploaders | |
parent | 74a2d57b337034cfdcd719615e4da06643b69114 (diff) | |
download | gitlab-ce-a6c2be7cd20a9515b347e72d63c5b47bb9b79457.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/uploaders')
-rw-r--r-- | spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb b/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb index 89a1fa80943..fcb8f4e51b5 100644 --- a/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb +++ b/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb @@ -3,12 +3,6 @@ require 'spec_helper' describe ObjectStorage::MigrateUploadsWorker do - shared_context 'sanity_check! fails' do - before do - expect(described_class).to receive(:sanity_check!).and_raise(described_class::SanityCheckError) - end - end - let(:model_class) { Project } let(:uploads) { Upload.all } let(:to_store) { ObjectStorage::Store::REMOTE } @@ -19,109 +13,6 @@ describe ObjectStorage::MigrateUploadsWorker do # swallow end - shared_examples "uploads migration worker" do - describe '.enqueue!' do - def enqueue! - described_class.enqueue!(uploads, Project, mounted_as, to_store) - end - - it 'is guarded by .sanity_check!' do - expect(described_class).to receive(:perform_async) - expect(described_class).to receive(:sanity_check!) - - enqueue! - end - - context 'sanity_check! fails' do - include_context 'sanity_check! fails' - - it 'does not enqueue a job' do - expect(described_class).not_to receive(:perform_async) - - expect { enqueue! }.to raise_error(described_class::SanityCheckError) - end - end - end - - describe '.sanity_check!' do - shared_examples 'raises a SanityCheckError' do |expected_message| - let(:mount_point) { nil } - - it do - expect { described_class.sanity_check!(uploads, model_class, mount_point) } - .to raise_error(described_class::SanityCheckError).with_message(expected_message) - end - end - - context 'uploader types mismatch' do - let!(:outlier) { create(:upload, uploader: 'GitlabUploader') } - - include_examples 'raises a SanityCheckError', /Multiple uploaders found/ - end - - context 'mount point not found' do - include_examples 'raises a SanityCheckError', /Mount point [a-z:]+ not found in/ do - let(:mount_point) { :potato } - end - end - end - - describe '#perform' do - shared_examples 'outputs correctly' do |success: 0, failures: 0| - total = success + failures - - if success > 0 - it 'outputs the reports' do - expect(Rails.logger).to receive(:info).with(%r{Migrated #{success}/#{total} files}) - - perform(uploads) - end - end - - if failures > 0 - it 'outputs upload failures' do - expect(Rails.logger).to receive(:warn).with(/Error .* I am a teapot/) - - perform(uploads) - end - end - end - - it_behaves_like 'outputs correctly', success: 10 - - it 'migrates files to remote storage' do - perform(uploads) - - expect(Upload.where(store: ObjectStorage::Store::LOCAL).count).to eq(0) - end - - context 'reversed' do - let(:to_store) { ObjectStorage::Store::LOCAL } - - before do - perform(uploads, ObjectStorage::Store::REMOTE) - end - - it 'migrates files to local storage' do - expect(Upload.where(store: ObjectStorage::Store::REMOTE).count).to eq(10) - - perform(uploads) - - expect(Upload.where(store: ObjectStorage::Store::LOCAL).count).to eq(10) - end - end - - context 'migration is unsuccessful' do - before do - allow_any_instance_of(ObjectStorage::Concern) - .to receive(:migrate!).and_raise(CarrierWave::UploadError, "I am a teapot.") - end - - it_behaves_like 'outputs correctly', failures: 10 - end - end - end - context "for AvatarUploader" do let!(:projects) { create_list(:project, 10, :with_avatar) } let(:mounted_as) { :avatar } |