diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-25 21:10:57 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-25 21:10:57 +0300 |
commit | 0351d9ed83635ce3258e2d09ba92b46a7cdcfa61 (patch) | |
tree | dd3c671fd8f618b87b9beeb7cf3a5b2ffa325253 /spec/models | |
parent | c59393a068f9d0113cc10ca8798d333d6a0e3d53 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/ci/build_spec.rb | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 9713734e97a..d9fb225e8c0 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -605,8 +605,8 @@ RSpec.describe Ci::Build do end end - describe '#prevent_rollback_deployment?' do - subject { build.prevent_rollback_deployment? } + describe '#outdated_deployment?' do + subject { build.outdated_deployment? } let(:build) { create(:ci_build, :created, :with_deployment, project: project, environment: 'production') } @@ -624,21 +624,33 @@ RSpec.describe Ci::Build do it { expect(subject).to be_falsey } end - context 'when deployment cannot rollback' do + context 'when build is not an outdated deployment' do before do - expect(build.deployment).to receive(:older_than_last_successful_deployment?).and_return(false) + allow(build.deployment).to receive(:older_than_last_successful_deployment?).and_return(false) end it { expect(subject).to be_falsey } end - context 'when build can prevent rollback deployment' do + context 'when build is older than the latest deployment and still pending status' do before do - expect(build.deployment).to receive(:older_than_last_successful_deployment?).and_return(true) + allow(build.deployment).to receive(:older_than_last_successful_deployment?).and_return(true) end it { expect(subject).to be_truthy } end + + context 'when build is older than the latest deployment but succeeded once' do + let(:build) { create(:ci_build, :success, :with_deployment, project: project, environment: 'production') } + + before do + allow(build.deployment).to receive(:older_than_last_successful_deployment?).and_return(true) + end + + it 'returns false for allowing rollback' do + expect(subject).to be_falsey + end + end end describe '#schedulable?' do |