diff options
Diffstat (limited to 'spec/support/shared_examples/services/schedule_bulk_repository_shard_moves_shared_examples.rb')
-rw-r--r-- | spec/support/shared_examples/services/schedule_bulk_repository_shard_moves_shared_examples.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/support/shared_examples/services/schedule_bulk_repository_shard_moves_shared_examples.rb b/spec/support/shared_examples/services/schedule_bulk_repository_shard_moves_shared_examples.rb new file mode 100644 index 00000000000..e67fc4ab04a --- /dev/null +++ b/spec/support/shared_examples/services/schedule_bulk_repository_shard_moves_shared_examples.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'moves repository shard in bulk' do + let(:source_storage_name) { 'default' } + let(:destination_storage_name) { 'test_second_storage' } + + before do + stub_storage_settings(destination_storage_name => { 'path' => 'tmp/tests/extra_storage' }) + end + + describe '#execute' do + it 'schedules container repository storage moves' do + expect { subject.execute(source_storage_name, destination_storage_name) } + .to change(move_service_klass, :count).by(1) + + storage_move = container.repository_storage_moves.last! + + expect(storage_move).to have_attributes( + source_storage_name: source_storage_name, + destination_storage_name: destination_storage_name, + state_name: :scheduled + ) + end + + context 'read-only repository' do + it 'does not get scheduled' do + container.set_repository_read_only! + + expect(subject).to receive(:log_info) + .with(/Container #{container.full_path} \(#{container.id}\) was skipped: #{container.class} is read only/) + expect { subject.execute(source_storage_name, destination_storage_name) } + .to change(move_service_klass, :count).by(0) + end + end + end + + describe '.enqueue' do + it 'defers to the worker' do + expect(bulk_worker_klass).to receive(:perform_async).with(source_storage_name, destination_storage_name) + + described_class.enqueue(source_storage_name, destination_storage_name) + end + end +end |