diff options
Diffstat (limited to 'spec/support/shared_examples/lib/gitlab')
3 files changed, 13 insertions, 56 deletions
diff --git a/spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb index 7888ade56eb..213f084be17 100644 --- a/spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb +++ b/spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb @@ -22,19 +22,19 @@ RSpec.shared_examples 'marks background migration job records' do end end -RSpec.shared_examples 'finalized background migration' do +RSpec.shared_examples 'finalized background migration' do |worker_class| it 'processed the scheduled sidekiq queue' do queued = Sidekiq::ScheduledSet .new .select do |scheduled| - scheduled.klass == 'BackgroundMigrationWorker' && + scheduled.klass == worker_class.name && scheduled.args.first == job_class_name end expect(queued.size).to eq(0) end it 'processed the async sidekiq queue' do - queued = Sidekiq::Queue.new('BackgroundMigrationWorker') + queued = Sidekiq::Queue.new(worker_class.name) .select { |scheduled| scheduled.klass == job_class_name } expect(queued.size).to eq(0) end @@ -42,8 +42,8 @@ RSpec.shared_examples 'finalized background migration' do include_examples 'removed tracked jobs', 'pending' end -RSpec.shared_examples 'finalized tracked background migration' do - include_examples 'finalized background migration' +RSpec.shared_examples 'finalized tracked background migration' do |worker_class| + include_examples 'finalized background migration', worker_class include_examples 'removed tracked jobs', 'succeeded' end diff --git a/spec/support/shared_examples/lib/gitlab/redis/multi_store_feature_flags_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/redis/multi_store_feature_flags_shared_examples.rb deleted file mode 100644 index 046c70bf779..00000000000 --- a/spec/support/shared_examples/lib/gitlab/redis/multi_store_feature_flags_shared_examples.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -RSpec.shared_examples 'multi store feature flags' do |use_primary_and_secondary_stores, use_primary_store_as_default| - context "with feature flag :#{use_primary_and_secondary_stores} is enabled" do - before do - stub_feature_flags(use_primary_and_secondary_stores => true) - end - - it 'multi store is enabled' do - expect(subject.use_primary_and_secondary_stores?).to be true - end - end - - context "with feature flag :#{use_primary_and_secondary_stores} is disabled" do - before do - stub_feature_flags(use_primary_and_secondary_stores => false) - end - - it 'multi store is disabled' do - expect(subject.use_primary_and_secondary_stores?).to be false - end - end - - context "with feature flag :#{use_primary_store_as_default} is enabled" do - before do - stub_feature_flags(use_primary_store_as_default => true) - end - - it 'primary store is enabled' do - expect(subject.use_primary_store_as_default?).to be true - end - end - - context "with feature flag :#{use_primary_store_as_default} is disabled" do - before do - stub_feature_flags(use_primary_store_as_default => false) - end - - it 'primary store is disabled' do - expect(subject.use_primary_store_as_default?).to be false - end - end -end diff --git a/spec/support/shared_examples/lib/gitlab/unique_ip_check_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/unique_ip_check_shared_examples.rb index e42a927b5ba..c735b98aa23 100644 --- a/spec/support/shared_examples/lib/gitlab/unique_ip_check_shared_examples.rb +++ b/spec/support/shared_examples/lib/gitlab/unique_ip_check_shared_examples.rb @@ -7,13 +7,13 @@ RSpec.shared_examples 'user login operation with unique ip limit' do end it 'allows user authenticating from the same ip' do - expect { operation_from_ip('ip') }.not_to raise_error - expect { operation_from_ip('ip') }.not_to raise_error + expect { operation_from_ip('111.221.4.3') }.not_to raise_error + expect { operation_from_ip('111.221.4.3') }.not_to raise_error end it 'blocks user authenticating from two distinct ips' do - expect { operation_from_ip('ip') }.not_to raise_error - expect { operation_from_ip('ip2') }.to raise_error(Gitlab::Auth::TooManyIps) + expect { operation_from_ip('111.221.4.3') }.not_to raise_error + expect { operation_from_ip('1.2.2.3') }.to raise_error(Gitlab::Auth::TooManyIps) end end end @@ -25,13 +25,13 @@ RSpec.shared_examples 'user login request with unique ip limit' do |success_stat end it 'allows user authenticating from the same ip' do - expect(request_from_ip('ip')).to have_gitlab_http_status(success_status) - expect(request_from_ip('ip')).to have_gitlab_http_status(success_status) + expect(request_from_ip('111.221.4.3')).to have_gitlab_http_status(success_status) + expect(request_from_ip('111.221.4.3')).to have_gitlab_http_status(success_status) end it 'blocks user authenticating from two distinct ips' do - expect(request_from_ip('ip')).to have_gitlab_http_status(success_status) - expect(request_from_ip('ip2')).to have_gitlab_http_status(:forbidden) + expect(request_from_ip('111.221.4.3')).to have_gitlab_http_status(success_status) + expect(request_from_ip('1.2.2.3')).to have_gitlab_http_status(:forbidden) end end end |