diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-05-18 11:50:31 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-05-18 11:50:31 +0000 |
commit | e330b709469747c65c3f7d6c13fac0ac8dca0615 (patch) | |
tree | 12212cd46bb6fd3c2ad24ae5ff34c3af2db3efd5 | |
parent | 40663fb94556195c4fc591bf3ad94936d670427f (diff) | |
parent | d476d08988476958efd5ff58f7600d0e46706fa2 (diff) | |
download | gitlab-ce-e330b709469747c65c3f7d6c13fac0ac8dca0615.tar.gz |
Merge branch 'fix/gb/not-allow-to-trigger-skipped-manual-actions' into 'master'
Do not allow to trigger manual actions that were skipped
Closes #42589
See merge request gitlab-org/gitlab-ce!18985
-rw-r--r-- | app/models/ci/build.rb | 2 | ||||
-rw-r--r-- | changelogs/unreleased/fix-gb-not-allow-to-trigger-skipped-manual-actions.yml | 5 | ||||
-rw-r--r-- | spec/models/ci/build_spec.rb | 40 |
3 files changed, 46 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/changelogs/unreleased/fix-gb-not-allow-to-trigger-skipped-manual-actions.yml b/changelogs/unreleased/fix-gb-not-allow-to-trigger-skipped-manual-actions.yml new file mode 100644 index 00000000000..c2a788d6ad0 --- /dev/null +++ b/changelogs/unreleased/fix-gb-not-allow-to-trigger-skipped-manual-actions.yml @@ -0,0 +1,5 @@ +--- +title: Do not allow to trigger manual actions that were skipped +merge_request: 18985 +author: +type: fixed 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 |