summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-07-17 13:00:32 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-07-17 13:00:32 +0200
commit7fde7012c9126172097fae57969f1694f7cf5f05 (patch)
tree607c0aea214478f00615a7e4c6c09a8dfb9a1cb0 /spec
parent9bb7f19d15ac5412a1d4c816f4b3eebcb3c5a840 (diff)
downloadgitlab-ce-7fde7012c9126172097fae57969f1694f7cf5f05.tar.gz
Make it possible to auto retry a failed CI/CD job
Diffstat (limited to 'spec')
-rw-r--r--spec/models/ci/build_spec.rb33
1 files changed, 32 insertions, 1 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index 615d1e09a11..acfc888d944 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -1624,7 +1624,7 @@ describe Ci::Build, :models do
end
end
- describe 'State transition: any => [:pending]' do
+ describe 'state transition: any => [:pending]' do
let(:build) { create(:ci_build, :created) }
it 'queues BuildQueueWorker' do
@@ -1633,4 +1633,35 @@ describe Ci::Build, :models do
build.enqueue
end
end
+
+ describe 'state transition when build fails' do
+ context 'when build is configured to be retried' do
+ subject { create(:ci_build, :running, options: { retry: 3 }) }
+
+ it 'retries builds and assigns a same user to it' do
+ expect(described_class).to receive(:retry)
+ .with(subject, subject.user)
+
+ subject.drop!
+ end
+ end
+
+ context 'when build is not configured to be retried' do
+ subject { create(:ci_build, :running) }
+
+ it 'does not retry build' do
+ expect(described_class).not_to receive(:retry)
+
+ subject.drop!
+ end
+
+ it 'does not count retries when not necessary' do
+ expect(described_class).not_to receive(:retry)
+ expect_any_instance_of(described_class)
+ .not_to receive(:retries_count)
+
+ subject.drop!
+ end
+ end
+ end
end