diff options
Diffstat (limited to 'spec/support/shared_examples/tasks/gitlab/uploads/migration_shared_examples.rb')
-rw-r--r-- | spec/support/shared_examples/tasks/gitlab/uploads/migration_shared_examples.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/support/shared_examples/tasks/gitlab/uploads/migration_shared_examples.rb b/spec/support/shared_examples/tasks/gitlab/uploads/migration_shared_examples.rb new file mode 100644 index 00000000000..b37a8059574 --- /dev/null +++ b/spec/support/shared_examples/tasks/gitlab/uploads/migration_shared_examples.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +# Expects the calling spec to define: +# - uploader_class +# - model_class +# - mounted_as +RSpec.shared_examples 'enqueue upload migration jobs in batch' do |batch:| + def run(task) + args = [uploader_class.to_s, model_class.to_s, mounted_as].compact + run_rake_task(task, *args) + end + + it 'migrates local storage to remote object storage' do + expect(ObjectStorage::MigrateUploadsWorker) + .to receive(:perform_async).exactly(batch).times + .and_return("A fake job.") + + run('gitlab:uploads:migrate') + end + + it 'migrates remote object storage to local storage' do + expect(Upload).to receive(:where).exactly(batch + 1).times { Upload.all } + expect(ObjectStorage::MigrateUploadsWorker) + .to receive(:perform_async) + .with(anything, model_class.name, mounted_as, ObjectStorage::Store::LOCAL) + .exactly(batch).times + .and_return("A fake job.") + + run('gitlab:uploads:migrate_to_local') + end +end |