diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-23 12:10:23 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-23 12:10:23 +0300 |
commit | a95a8847071680f16dbd7c0c0511f6492d00fc45 (patch) | |
tree | 1640e03fec815b8d11c992c64230a4d64929ac04 /spec/lib | |
parent | a5549176e1fb5780fa68778571f0eda563dcf090 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/database/background_migration/batched_migration_spec.rb | 36 | ||||
-rw-r--r-- | spec/lib/sidebars/menu_spec.rb | 23 | ||||
-rw-r--r-- | spec/lib/sidebars/projects/menus/monitor_menu_spec.rb | 19 |
3 files changed, 59 insertions, 19 deletions
diff --git a/spec/lib/gitlab/database/background_migration/batched_migration_spec.rb b/spec/lib/gitlab/database/background_migration/batched_migration_spec.rb index 3207e97a639..a1c2634f59c 100644 --- a/spec/lib/gitlab/database/background_migration/batched_migration_spec.rb +++ b/spec/lib/gitlab/database/background_migration/batched_migration_spec.rb @@ -234,6 +234,42 @@ RSpec.describe Gitlab::Database::BackgroundMigration::BatchedMigration, type: :m end end + describe '#retry_failed_jobs!' do + let(:batched_migration) { create(:batched_background_migration, status: 'failed') } + + subject(:retry_failed_jobs) { batched_migration.retry_failed_jobs! } + + context 'when there are failed migration jobs' do + let!(:batched_background_migration_job) { create(:batched_background_migration_job, batched_migration: batched_migration, batch_size: 10, min_value: 6, max_value: 15, status: :failed, attempts: 3) } + + before do + allow_next_instance_of(Gitlab::BackgroundMigration::BatchingStrategies::PrimaryKeyBatchingStrategy) do |batch_class| + allow(batch_class).to receive(:next_batch).with(anything, anything, batch_min_value: 6, batch_size: 5).and_return([6, 10]) + end + end + + it 'moves the status of the migration to active' do + retry_failed_jobs + + expect(batched_migration.status).to eql 'active' + end + + it 'changes the number of attempts to 0' do + retry_failed_jobs + + expect(batched_background_migration_job.reload.attempts).to be_zero + end + end + + context 'when there are no failed migration jobs' do + it 'moves the status of the migration to active' do + retry_failed_jobs + + expect(batched_migration.status).to eql 'active' + end + end + end + describe '#job_class_name=' do it_behaves_like 'an attr_writer that demodulizes assigned class names', :job_class_name end diff --git a/spec/lib/sidebars/menu_spec.rb b/spec/lib/sidebars/menu_spec.rb index 1db80351e45..eb6a68f1afd 100644 --- a/spec/lib/sidebars/menu_spec.rb +++ b/spec/lib/sidebars/menu_spec.rb @@ -198,4 +198,27 @@ RSpec.describe Sidebars::Menu do end end end + + describe '#link' do + let(:foo_path) { '/foo_path'} + + let(:foo_menu) do + ::Sidebars::MenuItem.new( + title: 'foo', + link: foo_path, + active_routes: {}, + item_id: :foo + ) + end + + it 'returns first visible menu item link' do + menu.add_item(foo_menu) + + expect(menu.link).to eq foo_path + end + + it 'returns nil if there are no visible menu items' do + expect(menu.link).to be_nil + end + end end diff --git a/spec/lib/sidebars/projects/menus/monitor_menu_spec.rb b/spec/lib/sidebars/projects/menus/monitor_menu_spec.rb index 381842be5ab..77efe99aaa9 100644 --- a/spec/lib/sidebars/projects/menus/monitor_menu_spec.rb +++ b/spec/lib/sidebars/projects/menus/monitor_menu_spec.rb @@ -49,25 +49,6 @@ RSpec.describe Sidebars::Projects::Menus::MonitorMenu do end end - describe '#link' do - let(:foo_path) { '/foo_path'} - - let(:foo_menu) do - ::Sidebars::MenuItem.new( - title: 'foo', - link: foo_path, - active_routes: {}, - item_id: :foo - ) - end - - it 'returns first visible item link' do - subject.insert_element_before(subject.renderable_items, subject.renderable_items.first.item_id, foo_menu) - - expect(subject.link).to eq foo_path - end - end - context 'Menu items' do subject { described_class.new(context).renderable_items.index { |e| e.item_id == item_id } } |