diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/models/commit_status_spec.rb | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/models/commit_status_spec.rb')
-rw-r--r-- | spec/models/commit_status_spec.rb | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb index d158a99ef9f..dbb15fad246 100644 --- a/spec/models/commit_status_spec.rb +++ b/spec/models/commit_status_spec.rb @@ -142,6 +142,26 @@ RSpec.describe CommitStatus do end end + describe '.cancelable' do + subject { described_class.cancelable } + + %i[running pending waiting_for_resource preparing created scheduled].each do |status| + context "when #{status} commit status" do + let!(:commit_status) { create(:commit_status, status, pipeline: pipeline) } + + it { is_expected.to contain_exactly(commit_status) } + end + end + + %i[failed success skipped canceled manual].each do |status| + context "when #{status} commit status" do + let!(:commit_status) { create(:commit_status, status, pipeline: pipeline) } + + it { is_expected.to be_empty } + end + end + end + describe '#started?' do subject { commit_status.started? } @@ -150,26 +170,28 @@ RSpec.describe CommitStatus do commit_status.started_at = nil end - it { is_expected.to be_falsey } + it { is_expected.to be(false) } end - %w[running success failed].each do |status| - context "if commit status is #{status}" do - before do - commit_status.status = status - end + context 'with started_at' do + described_class::STARTED_STATUSES.each do |status| + context "if commit status is #{status}" do + before do + commit_status.status = status + end - it { is_expected.to be_truthy } + it { is_expected.to eq(true) } + end end - end - %w[pending canceled].each do |status| - context "if commit status is #{status}" do - before do - commit_status.status = status - end + (described_class::AVAILABLE_STATUSES - described_class::STARTED_STATUSES).each do |status| + context "if commit status is #{status}" do + before do + commit_status.status = status + end - it { is_expected.to be_falsey } + it { is_expected.to be(false) } + end end end end |