diff options
Diffstat (limited to 'spec/services/ci')
18 files changed, 194 insertions, 224 deletions
diff --git a/spec/services/ci/compare_test_reports_service_spec.rb b/spec/services/ci/compare_test_reports_service_spec.rb index 01d58b2095f..6d3df0f5383 100644 --- a/spec/services/ci/compare_test_reports_service_spec.rb +++ b/spec/services/ci/compare_test_reports_service_spec.rb @@ -72,10 +72,11 @@ RSpec.describe Ci::CompareTestReportsService do it 'loads recent failures on limited test cases to avoid building up a huge DB query', :aggregate_failures do expect(comparison[:data]).to match_schema('entities/test_reports_comparer') - expect(recent_failures_per_test_case).to eq([ - { 'count' => 1, 'base_branch' => 'master' }, - { 'count' => 1, 'base_branch' => 'master' } - ]) + expect(recent_failures_per_test_case).to eq( + [ + { 'count' => 1, 'base_branch' => 'master' }, + { 'count' => 1, 'base_branch' => 'master' } + ]) expect(new_failures.count).to eq(2) end end diff --git a/spec/services/ci/create_pipeline_service/include_spec.rb b/spec/services/ci/create_pipeline_service/include_spec.rb index 67d8530525a..3764663fd74 100644 --- a/spec/services/ci/create_pipeline_service/include_spec.rb +++ b/spec/services/ci/create_pipeline_service/include_spec.rb @@ -126,51 +126,5 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes it_behaves_like 'not including the file' end end - - context 'with ci_increase_includes_to_250 enabled on root project' do - let_it_be(:included_project) do - create(:project, :repository).tap { |p| p.add_developer(user) } - end - - before do - stub_const('::Gitlab::Ci::Config::External::Context::MAX_INCLUDES', 0) - stub_const('::Gitlab::Ci::Config::External::Context::TRIAL_MAX_INCLUDES', 3) - - stub_feature_flags(ci_increase_includes_to_250: false) - stub_feature_flags(ci_increase_includes_to_250: project) - - allow(Project) - .to receive(:find_by_full_path) - .with(included_project.full_path) - .and_return(included_project) - - allow(included_project.repository) - .to receive(:blob_data_at).with(included_project.commit.id, '.gitlab-ci.yml') - .and_return(local_config) - - allow(included_project.repository) - .to receive(:blob_data_at).with(included_project.commit.id, file_location) - .and_return(File.read(Rails.root.join(file_location))) - end - - let(:config) do - <<~EOY - include: - - project: #{included_project.full_path} - file: .gitlab-ci.yml - EOY - end - - let(:local_config) do - <<~EOY - include: #{file_location} - - job: - script: exit 0 - EOY - end - - it_behaves_like 'including the file' - end end end diff --git a/spec/services/ci/create_pipeline_service/limit_active_jobs_spec.rb b/spec/services/ci/create_pipeline_service/limit_active_jobs_spec.rb new file mode 100644 index 00000000000..003d109a27c --- /dev/null +++ b/spec/services/ci/create_pipeline_service/limit_active_jobs_spec.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true +require 'spec_helper' + +RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectness do + let_it_be(:project) { create(:project, :repository) } + let_it_be(:user) { project.first_owner } + let_it_be(:existing_pipeline) { create(:ci_pipeline, project: project) } + + let(:service) { described_class.new(project, user, ref: 'refs/heads/master') } + + subject(:pipeline) { service.execute(:push).payload } + + before do + create_list(:ci_build, 8, pipeline: existing_pipeline) + create_list(:ci_bridge, 1, pipeline: existing_pipeline) + + stub_ci_pipeline_yaml_file(<<~YAML) + job1: + script: echo + job3: + trigger: + project: org/my-project + job4: + script: echo + only: [tags] + YAML + end + + context 'when project has exceeded the active jobs limit' do + before do + project.namespace.actual_limits.update!(ci_active_jobs: 10) + end + + it 'fails the pipeline before populating it' do + expect(pipeline).to be_failed + expect(pipeline).to be_job_activity_limit_exceeded + + expect(pipeline.errors.full_messages) + .to include("Project exceeded the allowed number of jobs in active pipelines. Retry later.") + expect(pipeline.statuses).to be_empty + end + end + + context 'when project has not exceeded the active jobs limit' do + before do + project.namespace.actual_limits.update!(ci_active_jobs: 20) + end + + it 'creates the pipeline successfully' do + expect(pipeline).to be_created + end + end +end diff --git a/spec/services/ci/create_pipeline_service/logger_spec.rb b/spec/services/ci/create_pipeline_service/logger_spec.rb index 2be23802757..3045f8e92b1 100644 --- a/spec/services/ci/create_pipeline_service/logger_spec.rb +++ b/spec/services/ci/create_pipeline_service/logger_spec.rb @@ -20,6 +20,7 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes { 'count' => a_kind_of(Numeric), 'avg' => a_kind_of(Numeric), + 'sum' => a_kind_of(Numeric), 'max' => a_kind_of(Numeric), 'min' => a_kind_of(Numeric) } diff --git a/spec/services/ci/create_pipeline_service/rules_spec.rb b/spec/services/ci/create_pipeline_service/rules_spec.rb index fc57ca66d3a..c737b8cc329 100644 --- a/spec/services/ci/create_pipeline_service/rules_spec.rb +++ b/spec/services/ci/create_pipeline_service/rules_spec.rb @@ -540,19 +540,10 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes let(:compare_to) { 'invalid-branch' } it 'returns an error' do - expect(pipeline.errors.full_messages).to eq([ - 'Failed to parse rule for job1: rules:changes:compare_to is not a valid ref' - ]) - end - - context 'when the FF ci_rules_changes_compare is not enabled' do - before do - stub_feature_flags(ci_rules_changes_compare: false) - end - - it 'ignores compare_to and changes is always true' do - expect(build_names).to contain_exactly('job1', 'job2') - end + expect(pipeline.errors.full_messages).to eq( + [ + 'Failed to parse rule for job1: rules:changes:compare_to is not a valid ref' + ]) end end @@ -563,16 +554,6 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes it 'creates job1 and job2' do expect(build_names).to contain_exactly('job1', 'job2') end - - context 'when the FF ci_rules_changes_compare is not enabled' do - before do - stub_feature_flags(ci_rules_changes_compare: false) - end - - it 'ignores compare_to and changes is always true' do - expect(build_names).to contain_exactly('job1', 'job2') - end - end end context 'when the rule does not match' do @@ -581,16 +562,6 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes it 'does not create job1' do expect(build_names).to contain_exactly('job2') end - - context 'when the FF ci_rules_changes_compare is not enabled' do - before do - stub_feature_flags(ci_rules_changes_compare: false) - end - - it 'ignores compare_to and changes is always true' do - expect(build_names).to contain_exactly('job1', 'job2') - end - end end end end @@ -616,17 +587,6 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes expect(pipeline).to be_created_successfully expect(build_names).to contain_exactly('job1') end - - context 'when the FF ci_rules_changes_compare is not enabled' do - before do - stub_feature_flags(ci_rules_changes_compare: false) - end - - it 'ignores compare_to and changes is always true' do - expect(pipeline).to be_created_successfully - expect(build_names).to contain_exactly('job1') - end - end end context 'when the rule does not match' do diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index c2e80316d26..458692ba1c0 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -293,7 +293,7 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes pipeline_on_previous_commit .builds .joins(:metadata) - .pluck(:name, 'ci_builds_metadata.interruptible') + .pluck(:name, "#{Ci::BuildMetadata.quoted_table_name}.interruptible") expect(interruptible_status).to contain_exactly( ['build_1_1', true], @@ -423,7 +423,7 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes expect(response.message).to eq('Missing CI config file') expect(response.payload).not_to be_persisted expect(Ci::Pipeline.count).to eq(0) - expect(Namespaces::OnboardingPipelineCreatedWorker).not_to receive(:perform_async) + expect(Onboarding::PipelineCreatedWorker).not_to receive(:perform_async) end shared_examples 'a failed pipeline' do @@ -1547,7 +1547,7 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes end it 'schedules a namespace onboarding create action worker' do - expect(Namespaces::OnboardingPipelineCreatedWorker) + expect(Onboarding::PipelineCreatedWorker) .to receive(:perform_async).with(project.namespace_id) pipeline diff --git a/spec/services/ci/find_exposed_artifacts_service_spec.rb b/spec/services/ci/find_exposed_artifacts_service_spec.rb index 32d96471f16..6e11c153a75 100644 --- a/spec/services/ci/find_exposed_artifacts_service_spec.rb +++ b/spec/services/ci/find_exposed_artifacts_service_spec.rb @@ -157,20 +157,21 @@ RSpec.describe Ci::FindExposedArtifactsService do subject { described_class.new(project, user).for_pipeline(pipeline, limit: 2) } it 'returns first 2 results' do - expect(subject).to eq([ - { - text: 'artifact 1', - url: file_project_job_artifacts_path(project, job1, 'ci_artifacts.txt'), - job_name: job1.name, - job_path: project_job_path(project, job1) - }, - { - text: 'artifact 2', - url: browse_project_job_artifacts_path(project, job2), - job_name: job2.name, - job_path: project_job_path(project, job2) - } - ]) + expect(subject).to eq( + [ + { + text: 'artifact 1', + url: file_project_job_artifacts_path(project, job1, 'ci_artifacts.txt'), + job_name: job1.name, + job_path: project_job_path(project, job1) + }, + { + text: 'artifact 2', + url: browse_project_job_artifacts_path(project, job2), + job_name: job2.name, + job_path: project_job_path(project, job2) + } + ]) end end @@ -199,20 +200,21 @@ RSpec.describe Ci::FindExposedArtifactsService do subject { described_class.new(project, user).for_pipeline(pipeline, limit: 2) } it 'returns the correct path for cross-project MRs' do - expect(subject).to eq([ - { - text: 'file artifact', - url: file_project_job_artifacts_path(foreign_project, job_show, 'ci_artifacts.txt'), - job_name: job_show.name, - job_path: project_job_path(foreign_project, job_show) - }, - { - text: 'directory artifact', - url: browse_project_job_artifacts_path(foreign_project, job_browse), - job_name: job_browse.name, - job_path: project_job_path(foreign_project, job_browse) - } - ]) + expect(subject).to eq( + [ + { + text: 'file artifact', + url: file_project_job_artifacts_path(foreign_project, job_show, 'ci_artifacts.txt'), + job_name: job_show.name, + job_path: project_job_path(foreign_project, job_show) + }, + { + text: 'directory artifact', + url: browse_project_job_artifacts_path(foreign_project, job_browse), + job_name: job_browse.name, + job_path: project_job_path(foreign_project, job_browse) + } + ]) end end end diff --git a/spec/services/ci/generate_kubeconfig_service_spec.rb b/spec/services/ci/generate_kubeconfig_service_spec.rb index e3088ca6ea7..bfde39780dd 100644 --- a/spec/services/ci/generate_kubeconfig_service_spec.rb +++ b/spec/services/ci/generate_kubeconfig_service_spec.rb @@ -9,6 +9,8 @@ RSpec.describe Ci::GenerateKubeconfigService do let(:pipeline) { build.pipeline } let(:agent1) { create(:cluster_agent, project: project) } let(:agent2) { create(:cluster_agent) } + let(:authorization1) { create(:agent_project_authorization, agent: agent1) } + let(:authorization2) { create(:agent_project_authorization, agent: agent2) } let(:template) { instance_double(Gitlab::Kubernetes::Kubeconfig::Template) } @@ -16,7 +18,7 @@ RSpec.describe Ci::GenerateKubeconfigService do before do expect(Gitlab::Kubernetes::Kubeconfig::Template).to receive(:new).and_return(template) - expect(pipeline).to receive(:authorized_cluster_agents).and_return([agent1, agent2]) + expect(pipeline).to receive(:cluster_agent_authorizations).and_return([authorization1, authorization2]) end it 'adds a cluster, and a user and context for each available agent' do @@ -36,11 +38,13 @@ RSpec.describe Ci::GenerateKubeconfigService do expect(template).to receive(:add_context).with( name: "#{project.full_path}:#{agent1.name}", + namespace: 'production', cluster: 'gitlab', user: "agent:#{agent1.id}" ) expect(template).to receive(:add_context).with( name: "#{agent2.project.full_path}:#{agent2.name}", + namespace: 'production', cluster: 'gitlab', user: "agent:#{agent2.id}" ) diff --git a/spec/services/ci/job_artifacts/create_service_spec.rb b/spec/services/ci/job_artifacts/create_service_spec.rb index a2259f9813b..030ba84951e 100644 --- a/spec/services/ci/job_artifacts/create_service_spec.rb +++ b/spec/services/ci/job_artifacts/create_service_spec.rb @@ -182,7 +182,8 @@ RSpec.describe Ci::JobArtifacts::CreateService do end context 'with job partitioning' do - let(:job) { create(:ci_build, project: project, partition_id: 123) } + let(:pipeline) { create(:ci_pipeline, project: project, partition_id: 123) } + let(:job) { create(:ci_build, pipeline: pipeline) } it 'sets partition_id on artifacts' do expect { subject }.to change { Ci::JobArtifact.count } diff --git a/spec/services/ci/job_artifacts/delete_service_spec.rb b/spec/services/ci/job_artifacts/delete_service_spec.rb index 62a755eb44a..78e8be48255 100644 --- a/spec/services/ci/job_artifacts/delete_service_spec.rb +++ b/spec/services/ci/job_artifacts/delete_service_spec.rb @@ -14,6 +14,7 @@ RSpec.describe Ci::JobArtifacts::DeleteService do result = service.execute expect(result).to be_success + expect(result[:destroyed_artifacts_count]).to be(2) end it 'deletes erasable artifacts' do @@ -24,7 +25,7 @@ RSpec.describe Ci::JobArtifacts::DeleteService do expect { service.execute }.not_to change { build.has_trace? }.from(true) end - context 'when project is undergoing statistics refresh' do + context 'when project is undergoing stats refresh' do before do allow(build.project).to receive(:refreshing_build_artifacts_size?).and_return(true) end @@ -36,6 +37,30 @@ RSpec.describe Ci::JobArtifacts::DeleteService do service.execute end + + it 'returns an error response with the correct message and reason' do + result = service.execute + + expect(result).to be_error + expect(result[:message]).to be('Action temporarily disabled. ' \ + 'The project this job belongs to is undergoing stats refresh.') + expect(result[:reason]).to be(:project_stats_refresh) + end + end + + context 'when an error response is received from DestroyBatchService' do + before do + allow_next_instance_of(Ci::JobArtifacts::DestroyBatchService) do |service| + allow(service).to receive(:execute).and_return({ status: :error, message: 'something went wrong' }) + end + end + + it 'returns an error response with the correct message' do + result = service.execute + + expect(result).to be_error + expect(result[:message]).to be('something went wrong') + end end end end diff --git a/spec/services/ci/job_token_scope/add_project_service_spec.rb b/spec/services/ci/job_token_scope/add_project_service_spec.rb index bb6df4268dd..bf7df3a5595 100644 --- a/spec/services/ci/job_token_scope/add_project_service_spec.rb +++ b/spec/services/ci/job_token_scope/add_project_service_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe Ci::JobTokenScope::AddProjectService do let(:service) { described_class.new(project, current_user) } - let_it_be(:project) { create(:project, ci_job_token_scope_enabled: true).tap(&:save!) } + let_it_be(:project) { create(:project, ci_outbound_job_token_scope_enabled: true).tap(&:save!) } let_it_be(:target_project) { create(:project) } let_it_be(:current_user) { create(:user) } diff --git a/spec/services/ci/job_token_scope/remove_project_service_spec.rb b/spec/services/ci/job_token_scope/remove_project_service_spec.rb index 155e60ac48e..c3f9081cbd8 100644 --- a/spec/services/ci/job_token_scope/remove_project_service_spec.rb +++ b/spec/services/ci/job_token_scope/remove_project_service_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe Ci::JobTokenScope::RemoveProjectService do let(:service) { described_class.new(project, current_user) } - let_it_be(:project) { create(:project, ci_job_token_scope_enabled: true).tap(&:save!) } + let_it_be(:project) { create(:project, ci_outbound_job_token_scope_enabled: true).tap(&:save!) } let_it_be(:target_project) { create(:project) } let_it_be(:current_user) { create(:user) } diff --git a/spec/services/ci/pipeline_artifacts/coverage_report_service_spec.rb b/spec/services/ci/pipeline_artifacts/coverage_report_service_spec.rb index 6d4dcf28108..c4558bddc85 100644 --- a/spec/services/ci/pipeline_artifacts/coverage_report_service_spec.rb +++ b/spec/services/ci/pipeline_artifacts/coverage_report_service_spec.rb @@ -35,6 +35,7 @@ RSpec.describe Ci::PipelineArtifacts::CoverageReportService do end it 'logs relevant information' do + allow(Gitlab::AppLogger).to receive(:info).and_call_original expect(Gitlab::AppLogger).to receive(:info).with({ project_id: project.id, pipeline_id: pipeline.id, @@ -52,28 +53,12 @@ RSpec.describe Ci::PipelineArtifacts::CoverageReportService do it_behaves_like 'creating or updating a pipeline coverage report' - context 'when ci_update_unlocked_pipeline_artifacts feature flag is enabled' do - it "artifact has pipeline's locked status" do - subject - - artifact = Ci::PipelineArtifact.first - - expect(artifact.locked).to eq(pipeline.locked) - end - end + it "artifact has pipeline's locked status" do + subject - context 'when ci_update_unlocked_pipeline_artifacts is disabled' do - before do - stub_feature_flags(ci_update_unlocked_pipeline_artifacts: false) - end - - it 'artifact has unknown locked status' do - subject + artifact = Ci::PipelineArtifact.first - artifact = Ci::PipelineArtifact.first - - expect(artifact.locked).to eq('unknown') - end + expect(artifact.locked).to eq(pipeline.locked) end end diff --git a/spec/services/ci/pipeline_artifacts/create_code_quality_mr_diff_report_service_spec.rb b/spec/services/ci/pipeline_artifacts/create_code_quality_mr_diff_report_service_spec.rb index 75233248113..5d854b61f14 100644 --- a/spec/services/ci/pipeline_artifacts/create_code_quality_mr_diff_report_service_spec.rb +++ b/spec/services/ci/pipeline_artifacts/create_code_quality_mr_diff_report_service_spec.rb @@ -51,28 +51,12 @@ RSpec.describe ::Ci::PipelineArtifacts::CreateCodeQualityMrDiffReportService do end end - context 'when ci_update_unlocked_pipeline_artifacts feature flag is enabled' do - it "artifact has pipeline's locked status" do - subject - - artifact = Ci::PipelineArtifact.first - - expect(artifact.locked).to eq(head_pipeline.locked) - end - end - - context 'when ci_update_unlocked_pipeline_artifacts is disabled' do - before do - stub_feature_flags(ci_update_unlocked_pipeline_artifacts: false) - end - - it 'artifact has unknown locked status' do - subject + it "artifact has pipeline's locked status" do + subject - artifact = Ci::PipelineArtifact.first + artifact = Ci::PipelineArtifact.first - expect(artifact.locked).to eq('unknown') - end + expect(artifact.locked).to eq(head_pipeline.locked) end it 'does not persist the same artifact twice' do diff --git a/spec/services/ci/pipeline_artifacts/destroy_all_expired_service_spec.rb b/spec/services/ci/pipeline_artifacts/destroy_all_expired_service_spec.rb index eb664043567..47e8766c215 100644 --- a/spec/services/ci/pipeline_artifacts/destroy_all_expired_service_spec.rb +++ b/spec/services/ci/pipeline_artifacts/destroy_all_expired_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Ci::PipelineArtifacts::DestroyAllExpiredService do +RSpec.describe Ci::PipelineArtifacts::DestroyAllExpiredService, :clean_gitlab_redis_shared_state do let(:service) { described_class.new } describe '.execute' do @@ -85,6 +85,36 @@ RSpec.describe Ci::PipelineArtifacts::DestroyAllExpiredService do is_expected.to eq(0) end end + + context 'with unlocked pipeline artifacts' do + let_it_be(:not_expired_artifact) { create(:ci_pipeline_artifact, :artifact_unlocked, expire_at: 2.days.from_now) } + + before do + create_list(:ci_pipeline_artifact, 2, :artifact_unlocked, expire_at: 1.week.ago) + allow(service).to receive(:legacy_destroy_pipeline_artifacts) + end + + it 'destroys all expired artifacts' do + expect { subject }.to change { Ci::PipelineArtifact.count }.by(-2) + expect(not_expired_artifact.reload).to be_present + end + + context 'when the loop limit is reached' do + before do + stub_const('::Ci::PipelineArtifacts::DestroyAllExpiredService::LOOP_LIMIT', 1) + stub_const('::Ci::PipelineArtifacts::DestroyAllExpiredService::BATCH_SIZE', 1) + end + + it 'destroys one artifact' do + expect { subject }.to change { Ci::PipelineArtifact.count }.by(-1) + expect(not_expired_artifact.reload).to be_present + end + + it 'reports the number of destroyed artifacts' do + is_expected.to eq(1) + end + end + end end describe '.destroy_artifacts_batch' do diff --git a/spec/services/ci/runners/register_runner_service_spec.rb b/spec/services/ci/runners/register_runner_service_spec.rb index 6d7b39de21e..2d1b109072f 100644 --- a/spec/services/ci/runners/register_runner_service_spec.rb +++ b/spec/services/ci/runners/register_runner_service_spec.rb @@ -9,7 +9,6 @@ RSpec.describe ::Ci::Runners::RegisterRunnerService, '#execute' do let(:runner) { execute.payload[:runner] } before do - stub_feature_flags(runner_registration_control: false) stub_application_setting(runners_registration_token: registration_token) stub_application_setting(valid_runner_registrars: ApplicationSetting::VALID_RUNNER_REGISTRAR_TYPES) end @@ -166,25 +165,9 @@ RSpec.describe ::Ci::Runners::RegisterRunnerService, '#execute' do stub_application_setting(valid_runner_registrars: ['group']) end - context 'when feature flag is enabled' do - before do - stub_feature_flags(runner_registration_control: true) - end - - it 'returns 403 error' do - expect(execute).to be_error - expect(execute.http_status).to eq :forbidden - end - end - - context 'when feature flag is disabled' do - it 'registers the runner' do - expect(execute).to be_success - - expect(runner).to be_an_instance_of(::Ci::Runner) - expect(runner.errors).to be_empty - expect(runner.active).to be true - end + it 'returns 403 error' do + expect(execute).to be_error + expect(execute.http_status).to eq :forbidden end end end @@ -244,24 +227,8 @@ RSpec.describe ::Ci::Runners::RegisterRunnerService, '#execute' do stub_application_setting(valid_runner_registrars: ['project']) end - context 'when feature flag is enabled' do - before do - stub_feature_flags(runner_registration_control: true) - end - - it 'returns error response' do - is_expected.to be_error - end - end - - context 'when feature flag is disabled' do - it 'registers the runner' do - expect(execute).to be_success - - expect(runner).to be_an_instance_of(::Ci::Runner) - expect(runner.errors).to be_empty - expect(runner.active).to be true - end + it 'returns error response' do + is_expected.to be_error end end end diff --git a/spec/services/ci/runners/set_runner_associated_projects_service_spec.rb b/spec/services/ci/runners/set_runner_associated_projects_service_spec.rb index 0d2e237c87b..1f44612947b 100644 --- a/spec/services/ci/runners/set_runner_associated_projects_service_spec.rb +++ b/spec/services/ci/runners/set_runner_associated_projects_service_spec.rb @@ -47,7 +47,11 @@ RSpec.describe ::Ci::Runners::SetRunnerAssociatedProjectsService, '#execute' do it 'reassigns associated projects and returns success response' do expect(execute).to be_success - expect(runner.reload.projects.ids).to eq([owner_project.id] + project_ids) + + runner.reload + + expect(runner.owner_project).to eq(owner_project) + expect(runner.projects.ids).to match_array([owner_project.id] + project_ids) end end @@ -56,7 +60,11 @@ RSpec.describe ::Ci::Runners::SetRunnerAssociatedProjectsService, '#execute' do it 'reassigns associated projects and returns success response' do expect(execute).to be_success - expect(runner.reload.projects.ids).to eq([owner_project.id] + project_ids) + + runner.reload + + expect(runner.owner_project).to eq(owner_project) + expect(runner.projects.ids).to match_array([owner_project.id] + project_ids) end end end diff --git a/spec/services/ci/unlock_artifacts_service_spec.rb b/spec/services/ci/unlock_artifacts_service_spec.rb index 776019f03f8..f21afc7fe9e 100644 --- a/spec/services/ci/unlock_artifacts_service_spec.rb +++ b/spec/services/ci/unlock_artifacts_service_spec.rb @@ -5,15 +5,11 @@ require 'spec_helper' RSpec.describe Ci::UnlockArtifactsService do using RSpec::Parameterized::TableSyntax - where(:tag, :ci_update_unlocked_job_artifacts, :ci_update_unlocked_pipeline_artifacts) do - false | false | false - false | true | false - true | false | false - true | true | false - false | false | true - false | true | true - true | false | true - true | true | true + where(:tag, :ci_update_unlocked_job_artifacts) do + false | false + false | true + true | false + true | true end with_them do @@ -35,8 +31,7 @@ RSpec.describe Ci::UnlockArtifactsService do before do stub_const("#{described_class}::BATCH_SIZE", 1) - stub_feature_flags(ci_update_unlocked_job_artifacts: ci_update_unlocked_job_artifacts, - ci_update_unlocked_pipeline_artifacts: ci_update_unlocked_pipeline_artifacts) + stub_feature_flags(ci_update_unlocked_job_artifacts: ci_update_unlocked_job_artifacts) end describe '#execute' do @@ -80,7 +75,7 @@ RSpec.describe Ci::UnlockArtifactsService do end it 'unlocks pipeline artifact records' do - if ci_update_unlocked_job_artifacts && ci_update_unlocked_pipeline_artifacts + if ci_update_unlocked_job_artifacts expect { execute }.to change { ::Ci::PipelineArtifact.artifact_unlocked.count }.from(0).to(1) else expect { execute }.not_to change { ::Ci::PipelineArtifact.artifact_unlocked.count } @@ -122,7 +117,7 @@ RSpec.describe Ci::UnlockArtifactsService do end it 'unlocks pipeline artifact records' do - if ci_update_unlocked_job_artifacts && ci_update_unlocked_pipeline_artifacts + if ci_update_unlocked_job_artifacts expect { execute }.to change { ::Ci::PipelineArtifact.artifact_unlocked.count }.from(0).to(1) else expect { execute }.not_to change { ::Ci::PipelineArtifact.artifact_unlocked.count } |