diff options
Diffstat (limited to 'spec/support/shared_examples/lib/gitlab')
5 files changed, 57 insertions, 26 deletions
diff --git a/spec/support/shared_examples/lib/gitlab/database/reestablished_connection_stack_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/database/reestablished_connection_stack_shared_examples.rb index d14216ec5ff..22b4f9f583c 100644 --- a/spec/support/shared_examples/lib/gitlab/database/reestablished_connection_stack_shared_examples.rb +++ b/spec/support/shared_examples/lib/gitlab/database/reestablished_connection_stack_shared_examples.rb @@ -3,9 +3,6 @@ RSpec.shared_context 'reconfigures connection stack' do |db_config_name| before do skip_if_multiple_databases_not_setup - - # Due to lib/gitlab/database/load_balancing/configuration.rb:92 requiring RequestStore - # we cannot use stub_feature_flags(force_no_sharing_primary_model: true) Gitlab::Database.database_base_models.each do |_, model_class| allow(model_class.load_balancer.configuration).to receive(:use_dedicated_connection?).and_return(true) end diff --git a/spec/support/shared_examples/lib/gitlab/event_store_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/event_store_shared_examples.rb index db2f2f2d0f0..e97b9ad969f 100644 --- a/spec/support/shared_examples/lib/gitlab/event_store_shared_examples.rb +++ b/spec/support/shared_examples/lib/gitlab/event_store_shared_examples.rb @@ -15,6 +15,16 @@ RSpec.shared_examples 'subscribes to event' do it_behaves_like 'an idempotent worker' end +RSpec.shared_examples 'ignores the published event' do + include AfterNextHelpers + + it 'does not consume the published event', :sidekiq_inline do + expect_next(described_class).not_to receive(:handle_event) + + ::Gitlab::EventStore.publish(event) + end +end + def consume_event(subscriber:, event:) subscriber.new.perform(event.class.name, event.data) end diff --git a/spec/support/shared_examples/lib/gitlab/experimentation_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/experimentation_shared_examples.rb deleted file mode 100644 index fdca326dbea..00000000000 --- a/spec/support/shared_examples/lib/gitlab/experimentation_shared_examples.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -RSpec.shared_examples 'tracks assignment and records the subject' do |experiment, subject_type| - before do - stub_experiments(experiment => true) - end - - it 'tracks the assignment', :experiment do - expect(experiment(experiment)) - .to track(:assignment) - .with_context(subject_type => subject) - .on_next_instance - - action - end - - it 'records the subject' do - expect(Experiment).to receive(:add_subject).with(experiment.to_s, variant: anything, subject: subject) - - action - end -end diff --git a/spec/support/shared_examples/lib/gitlab/gitaly_client_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/gitaly_client_shared_examples.rb new file mode 100644 index 00000000000..f26b9a4a7bd --- /dev/null +++ b/spec/support/shared_examples/lib/gitlab/gitaly_client_shared_examples.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +def raw_repo_without_container(repository) + Gitlab::Git::Repository.new(repository.shard, + "#{repository.disk_path}.git", + repository.repo_type.identifier_for_container(repository.container), + repository.container.full_path) +end + +RSpec.shared_examples 'Gitaly feature flag actors are inferred from repository' do + it 'captures correct actors' do + service.repository_actor = repository + + expect(service.repository_actor.flipper_id).to eql(repository.flipper_id) + + if expected_project.nil? + expect(service.project_actor).to be(nil) + else + expect(service.project_actor.flipper_id).to eql(expected_project.flipper_id) + end + + if expected_group.nil? + expect(service.group_actor).to be(nil) + else + expect(service.group_actor.flipper_id).to eql(expected_group.flipper_id) + end + end + + it 'does not issues SQL queries after the first invocation' do + service.repository_actor = repository + + service.repository_actor + service.project_actor + service.group_actor + + recorder = ActiveRecord::QueryRecorder.new do + 3.times do + service.repository_actor + service.project_actor + service.group_actor + end + end + + expect(recorder.count).to be(0) + end +end diff --git a/spec/support/shared_examples/lib/gitlab/template/template_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/template/template_shared_examples.rb index 4b4a7f4ce9d..a2a4c57d62e 100644 --- a/spec/support/shared_examples/lib/gitlab/template/template_shared_examples.rb +++ b/spec/support/shared_examples/lib/gitlab/template/template_shared_examples.rb @@ -52,7 +52,7 @@ RSpec.shared_examples 'acts as branch pipeline' do |jobs| context 'when branch pipeline' do let(:pipeline_branch) { default_branch } let(:service) { Ci::CreatePipelineService.new(project, user, ref: pipeline_branch) } - let(:pipeline) { service.execute!(:push).payload } + let(:pipeline) { service.execute(:push).payload } it 'includes a job' do expect(pipeline.builds.pluck(:name)).to match_array(jobs) |