summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-05-16 14:02:04 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-05-16 14:07:14 +0200
commit3a94919e83f1e5b359f6772762392eeda2d7134d (patch)
treeabdb2bb250a264bd9d59d7e5147256e63f06f131
parenta78b1b27b86d34c00e1b0631e967d637f8a6714b (diff)
downloadgitlab-ce-3a94919e83f1e5b359f6772762392eeda2d7134d.tar.gz
Do not allow to trigger manual actions that were skipped
-rw-r--r--app/models/ci/build.rb2
-rw-r--r--spec/models/ci/build_spec.rb40
2 files changed, 41 insertions, 1 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 61c10c427dd..d9649e30edc 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -184,7 +184,7 @@ module Ci
end
def playable?
- action? && (manual? || complete?)
+ action? && (manual? || retryable?)
end
def action?
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index dc810489011..7d8bddbcedb 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -1270,6 +1270,46 @@ describe Ci::Build do
end
end
+ describe '#playable?' do
+ context 'when build is a manual action' do
+ context 'when build has been skipped' do
+ subject { build_stubbed(:ci_build, :manual, status: :skipped) }
+
+ it { is_expected.not_to be_playable }
+ end
+
+ context 'when build has been canceled' do
+ subject { build_stubbed(:ci_build, :manual, status: :canceled) }
+
+ it { is_expected.to be_playable }
+ end
+
+ context 'when build is successful' do
+ subject { build_stubbed(:ci_build, :manual, status: :success) }
+
+ it { is_expected.to be_playable }
+ end
+
+ context 'when build has failed' do
+ subject { build_stubbed(:ci_build, :manual, status: :failed) }
+
+ it { is_expected.to be_playable }
+ end
+
+ context 'when build is a manual untriggered action' do
+ subject { build_stubbed(:ci_build, :manual, status: :manual) }
+
+ it { is_expected.to be_playable }
+ end
+ end
+
+ context 'when build is not a manual action' do
+ subject { build_stubbed(:ci_build, :success) }
+
+ it { is_expected.not_to be_playable }
+ end
+ end
+
describe 'project settings' do
describe '#allow_git_fetch' do
it 'return project allow_git_fetch configuration' do