summaryrefslogtreecommitdiff
path: root/spec/models/ci/pipeline_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-03-18 20:02:30 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-03-18 20:02:30 +0000
commit41fe97390ceddf945f3d967b8fdb3de4c66b7dea (patch)
tree9c8d89a8624828992f06d892cd2f43818ff5dcc8 /spec/models/ci/pipeline_spec.rb
parent0804d2dc31052fb45a1efecedc8e06ce9bc32862 (diff)
downloadgitlab-ce-41fe97390ceddf945f3d967b8fdb3de4c66b7dea.tar.gz
Add latest changes from gitlab-org/gitlab@14-9-stable-eev14.9.0-rc42
Diffstat (limited to 'spec/models/ci/pipeline_spec.rb')
-rw-r--r--spec/models/ci/pipeline_spec.rb37
1 files changed, 28 insertions, 9 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index c29cc04e0e9..294ec07ee3e 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -438,15 +438,6 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
it { expect(pipeline).not_to be_merge_request }
end
-
- context 'when the feature flag is disabled' do
- before do
- stub_feature_flags(ci_pipeline_merge_request_presence_check: false)
- pipeline.update!(merge_request_id: non_existing_record_id)
- end
-
- it { expect(pipeline).to be_merge_request }
- end
end
describe '#detached_merge_request_pipeline?' do
@@ -2890,6 +2881,34 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
+ describe '.cancelable' do
+ subject { described_class.cancelable }
+
+ shared_examples 'containing the pipeline' do |status|
+ context "when it's #{status} pipeline" do
+ let!(:pipeline) { create(:ci_pipeline, status: status) }
+
+ it { is_expected.to contain_exactly(pipeline) }
+ end
+ end
+
+ shared_examples 'not containing the pipeline' do |status|
+ context "when it's #{status} pipeline" do
+ let!(:pipeline) { create(:ci_pipeline, status: status) }
+
+ it { is_expected.to be_empty }
+ end
+ end
+
+ %i[running pending waiting_for_resource preparing created scheduled manual].each do |status|
+ it_behaves_like 'containing the pipeline', status
+ end
+
+ %i[failed success skipped canceled].each do |status|
+ it_behaves_like 'not containing the pipeline', status
+ end
+ end
+
describe '#retry_failed' do
subject(:latest_status) { pipeline.latest_statuses.pluck(:status) }