diff options
Diffstat (limited to 'spec/lib/gitlab/ci/pipeline')
4 files changed, 9 insertions, 71 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb index e3061f8095b..16517b39a45 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::External do let_it_be(:project) { create(:project) } - let_it_be(:user) { create(:user) } + let_it_be(:user) { create(:user, :with_sign_ins) } let(:pipeline) { build(:ci_empty_pipeline, user: user, project: project) } let!(:step) { described_class.new(pipeline, command) } @@ -43,7 +43,6 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::External do end let(:save_incompleted) { true } - let(:dot_com) { true } let(:command) do Gitlab::Ci::Pipeline::Chain::Command.new( project: project, current_user: user, yaml_processor_result: yaml_processor_result, save_incompleted: save_incompleted @@ -57,7 +56,6 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::External do before do stub_env('EXTERNAL_VALIDATION_SERVICE_URL', validation_service_url) - allow(Gitlab).to receive(:com?).and_return(dot_com) allow(Labkit::Correlation::CorrelationId).to receive(:current_id).and_return('correlation-id') end @@ -199,61 +197,6 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::External do end end - context 'when the feature flag is disabled' do - before do - stub_feature_flags(ci_external_validation_service: false) - stub_request(:post, validation_service_url) - end - - it 'does not drop the pipeline' do - perform! - - expect(pipeline.status).not_to eq('failed') - expect(pipeline.errors).to be_empty - end - - it 'does not break the chain' do - perform! - - expect(step.break?).to be false - end - - it 'does not make requests' do - perform! - - expect(WebMock).not_to have_requested(:post, validation_service_url) - end - end - - context 'when not on .com' do - let(:dot_com) { false } - - before do - stub_feature_flags(ci_external_validation_service: false) - stub_request(:post, validation_service_url).to_return(status: 404, body: "{}") - end - - it 'drops the pipeline' do - perform! - - expect(pipeline.status).to eq('failed') - expect(pipeline).to be_persisted - expect(pipeline.errors.to_a).to include('External validation failed') - end - - it 'breaks the chain' do - perform! - - expect(step.break?).to be true - end - - it 'logs the authorization' do - expect(Gitlab::AppLogger).to receive(:info).with(message: 'Pipeline not authorized', project_id: project.id, user_id: user.id) - - perform! - end - end - context 'when validation returns 406 Not Acceptable' do before do stub_request(:post, validation_service_url).to_return(status: 406, body: "{}") diff --git a/spec/lib/gitlab/ci/pipeline/preloader_spec.rb b/spec/lib/gitlab/ci/pipeline/preloader_spec.rb index ae423fa04f9..5b644e42451 100644 --- a/spec/lib/gitlab/ci/pipeline/preloader_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/preloader_spec.rb @@ -5,9 +5,11 @@ require 'spec_helper' RSpec.describe Gitlab::Ci::Pipeline::Preloader do let(:stage) { double(:stage) } let(:commit) { double(:commit) } + let(:scheduled_action) { double(:scheduled_action) } + let(:manual_action) { double(:manual_action) } let(:pipeline) do - double(:pipeline, commit: commit, stages: [stage]) + double(:pipeline, commit: commit, stages: [stage], scheduled_actions: [scheduled_action], manual_actions: [manual_action]) end describe '.preload!' do @@ -33,6 +35,8 @@ RSpec.describe Gitlab::Ci::Pipeline::Preloader do expect(pipeline).to receive(:lazy_ref_commit) expect(pipeline).to receive(:number_of_warnings) expect(stage).to receive(:number_of_warnings) + expect(scheduled_action).to receive(:persisted_environment) + expect(manual_action).to receive(:persisted_environment) described_class.preload!([pipeline]) end @@ -42,6 +46,8 @@ RSpec.describe Gitlab::Ci::Pipeline::Preloader do allow(pipeline).to receive(:lazy_ref_commit) allow(pipeline).to receive(:number_of_warnings) allow(stage).to receive(:number_of_warnings) + allow(scheduled_action).to receive(:persisted_environment) + allow(manual_action).to receive(:persisted_environment) pipelines = [pipeline, pipeline] diff --git a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb index 058fb25807d..020f957cf70 100644 --- a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb @@ -1101,17 +1101,6 @@ RSpec.describe Gitlab::Ci::Pipeline::Seed::Build do it "does not return an error" do expect(subject.errors).to be_empty end - - context 'when the FF ci_needs_optional is disabled' do - before do - stub_feature_flags(ci_needs_optional: false) - end - - it "returns an error" do - expect(subject.errors).to contain_exactly( - "'rspec' job needs 'build' job, but it was not added to the pipeline") - end - end end end diff --git a/spec/lib/gitlab/ci/pipeline/seed/environment_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/environment_spec.rb index 175b12637e6..ad89f1f5cda 100644 --- a/spec/lib/gitlab/ci/pipeline/seed/environment_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/seed/environment_spec.rb @@ -128,7 +128,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Seed::Environment do context 'when environment has already been created' do before do - create(:environment, :staging, project: project, name: 'customer-portal') + create(:environment, project: project, name: 'customer-portal', tier: :staging) end it 'does not overwrite the specified deployment tier' do |