summaryrefslogtreecommitdiff
path: root/spec/models/commit_status_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/commit_status_spec.rb')
-rw-r--r--spec/models/commit_status_spec.rb66
1 files changed, 60 insertions, 6 deletions
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb
index 31aebac54e1..40652614101 100644
--- a/spec/models/commit_status_spec.rb
+++ b/spec/models/commit_status_spec.rb
@@ -63,6 +63,42 @@ describe CommitStatus do
end
end
+ describe '#processed' do
+ subject { commit_status.processed }
+
+ context 'when ci_atomic_processing is disabled' do
+ before do
+ stub_feature_flags(ci_atomic_processing: false)
+
+ commit_status.save!
+ end
+
+ it { is_expected.to be_nil }
+ end
+
+ context 'when ci_atomic_processing is enabled' do
+ before do
+ stub_feature_flags(ci_atomic_processing: true)
+ end
+
+ context 'status is latest' do
+ before do
+ commit_status.update!(retried: false, status: :pending)
+ end
+
+ it { is_expected.to be_falsey }
+ end
+
+ context 'status is retried' do
+ before do
+ commit_status.update!(retried: true, status: :pending)
+ end
+
+ it { is_expected.to be_truthy }
+ end
+ end
+ end
+
describe '#started?' do
subject { commit_status.started? }
@@ -634,6 +670,30 @@ describe CommitStatus do
end
end
+ describe '#all_met_to_become_pending?' do
+ subject { commit_status.all_met_to_become_pending? }
+
+ let(:commit_status) { create(:commit_status) }
+
+ it { is_expected.to eq(true) }
+
+ context 'when build requires a resource' do
+ before do
+ allow(commit_status).to receive(:requires_resource?) { true }
+ end
+
+ it { is_expected.to eq(false) }
+ end
+
+ context 'when build has a prerequisite' do
+ before do
+ allow(commit_status).to receive(:any_unmet_prerequisites?) { true }
+ end
+
+ it { is_expected.to eq(false) }
+ end
+ end
+
describe '#enqueue' do
let!(:current_time) { Time.new(2018, 4, 5, 14, 0, 0) }
@@ -654,12 +714,6 @@ describe CommitStatus do
it_behaves_like 'commit status enqueued'
end
- context 'when initial state is :preparing' do
- let(:commit_status) { create(:commit_status, :preparing) }
-
- it_behaves_like 'commit status enqueued'
- end
-
context 'when initial state is :skipped' do
let(:commit_status) { create(:commit_status, :skipped) }