diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-07-11 15:42:00 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-07-11 15:42:00 +0200 |
commit | 388abbd10c043b4cc406fa717e05dd81b0858c02 (patch) | |
tree | 8fa0aebe2a67d5efcf9d1227dbc3d3d8b8228e46 /spec/lib/gitlab/background_migration_spec.rb | |
parent | c17b1d5f5651b6f73b8c999bb6a5376e31a7d30d (diff) | |
download | gitlab-ce-388abbd10c043b4cc406fa717e05dd81b0858c02.tar.gz |
Extract background migratons queue class method
Diffstat (limited to 'spec/lib/gitlab/background_migration_spec.rb')
-rw-r--r-- | spec/lib/gitlab/background_migration_spec.rb | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/spec/lib/gitlab/background_migration_spec.rb b/spec/lib/gitlab/background_migration_spec.rb index 64f82fe27b2..93ffaab65ce 100644 --- a/spec/lib/gitlab/background_migration_spec.rb +++ b/spec/lib/gitlab/background_migration_spec.rb @@ -1,33 +1,38 @@ require 'spec_helper' describe Gitlab::BackgroundMigration do - describe '.steal' do - it 'steals jobs from a queue' do - queue = [double(:job, args: ['Foo', [10, 20]])] - - allow(Sidekiq::Queue).to receive(:new) - .with(BackgroundMigrationWorker.sidekiq_options['queue']) - .and_return(queue) + describe '.queue' do + it 'returns background migration worker queue' do + expect(described_class.queue) + .to eq BackgroundMigrationWorker.sidekiq_options['queue'] + end + end - expect(queue[0]).to receive(:delete) + describe '.steal' do + context 'when there are enqueued jobs present' do + let(:queue) { [double(:job, args: ['Foo', [10, 20]])] } - expect(described_class).to receive(:perform).with('Foo', [10, 20]) + before do + allow(Sidekiq::Queue).to receive(:new) + .with(described_class.queue) + .and_return(queue) + end - described_class.steal('Foo') - end + it 'steals jobs from a queue' do + expect(queue[0]).to receive(:delete) - it 'does not steal jobs for a different migration' do - queue = [double(:job, args: ['Foo', [10, 20]])] + expect(described_class).to receive(:perform).with('Foo', [10, 20]) - allow(Sidekiq::Queue).to receive(:new) - .with(BackgroundMigrationWorker.sidekiq_options['queue']) - .and_return(queue) + described_class.steal('Foo') + end - expect(described_class).not_to receive(:perform) + it 'does not steal jobs for a different migration' do + expect(described_class).not_to receive(:perform) - expect(queue[0]).not_to receive(:delete) + expect(queue[0]).not_to receive(:delete) - described_class.steal('Bar') + described_class.steal('Bar') + end end end |