diff options
Diffstat (limited to 'spec/models/ci/build_spec.rb')
-rw-r--r-- | spec/models/ci/build_spec.rb | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index b7de8ca4337..b9a12339e61 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -29,7 +29,7 @@ RSpec.describe Ci::Build do it { is_expected.to have_one(:deployment) } it { is_expected.to have_one(:runner_session) } it { is_expected.to have_one(:trace_metadata) } - it { is_expected.to have_many(:terraform_state_versions).dependent(:nullify).inverse_of(:build) } + it { is_expected.to have_many(:terraform_state_versions).inverse_of(:build) } it { is_expected.to validate_presence_of(:ref) } @@ -1994,6 +1994,14 @@ RSpec.describe Ci::Build do it { is_expected.not_to be_retryable } end + + context 'when deployment is rejected' do + before do + build.drop!(:deployment_rejected) + end + + it { is_expected.not_to be_retryable } + end end end @@ -2498,7 +2506,7 @@ RSpec.describe Ci::Build do it { is_expected.to start_with(project.web_url[0..6]) } it { is_expected.to include(build.token) } it { is_expected.to include('gitlab-ci-token') } - it { is_expected.to include(project.web_url[7..-1]) } + it { is_expected.to include(project.web_url[7..]) } end context 'when token is empty' do @@ -3421,10 +3429,6 @@ RSpec.describe Ci::Build do end describe '#scoped_variables' do - before do - pipeline.clear_memoization(:predefined_vars_in_builder_enabled) - end - it 'records a prometheus metric' do histogram = double(:histogram) expect(::Gitlab::Ci::Pipeline::Metrics).to receive(:pipeline_builder_scoped_variables_histogram) @@ -3522,22 +3526,6 @@ RSpec.describe Ci::Build do build.scoped_variables end - - context 'when ci builder feature flag is disabled' do - before do - stub_feature_flags(ci_predefined_vars_in_builder: false) - end - - it 'does not delegate to the variable builders' do - expect_next_instance_of(Gitlab::Ci::Variables::Builder) do |builder| - expect(builder).not_to receive(:predefined_variables) - end - - build.scoped_variables - end - - it_behaves_like 'calculates scoped_variables' - end end describe '#simple_variables_without_dependencies' do @@ -3782,6 +3770,12 @@ RSpec.describe Ci::Build do build.enqueue end + + it 'queues BuildHooksWorker' do + expect(BuildHooksWorker).to receive(:perform_async).with(build.id) + + build.enqueue + end end describe 'state transition: pending: :running' do @@ -4474,7 +4468,7 @@ RSpec.describe Ci::Build do 'create' => 0, 'update' => 1, 'delete' => 0, - 'job_name' => build.options.dig(:artifacts, :name).to_s + 'job_name' => build.name ) ) ) @@ -5423,4 +5417,13 @@ RSpec.describe Ci::Build do expect(subject).to be true end end + + it_behaves_like 'it has loose foreign keys' do + let(:factory_name) { :ci_build } + end + + it_behaves_like 'cleanup by a loose foreign key' do + let!(:model) { create(:ci_build, user: create(:user)) } + let!(:parent) { model.user } + end end |