diff options
| author | Shinya Maeda <shinya@gitlab.com> | 2017-08-28 21:10:01 +0900 |
|---|---|---|
| committer | Shinya Maeda <shinya@gitlab.com> | 2017-09-03 23:49:10 +0900 |
| commit | 4b0e31ba64118011ffc29c31bc771fa2568cd270 (patch) | |
| tree | 21f4a5273bf28c514ede0a698b2c2459a3710a75 | |
| parent | 6fbb3ce6e93b8dfba795d4542fcb5602c4c82eaf (diff) | |
| download | gitlab-ce-4b0e31ba64118011ffc29c31bc771fa2568cd270.tar.gz | |
Extend can_pick?
| -rw-r--r-- | app/models/ci/runner.rb | 2 | ||||
| -rw-r--r-- | spec/models/ci/runner_spec.rb | 24 |
2 files changed, 26 insertions, 0 deletions
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index 24b62555845..a3b4a1fccf3 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -111,6 +111,8 @@ module Ci end def can_pick?(build) + return false if self.protected_? && !build.protected? + assignable_for?(build.project) && accepting_tags?(build) end diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb index a04d4615b6b..566b9b48879 100644 --- a/spec/models/ci/runner_spec.rb +++ b/spec/models/ci/runner_spec.rb @@ -95,6 +95,8 @@ describe Ci::Runner do let(:build) { create(:ci_build, pipeline: pipeline) } let(:runner) { create(:ci_runner) } + subject { runner.can_pick?(build) } + before do build.project.runners << runner end @@ -222,6 +224,28 @@ describe Ci::Runner do end end end + + context 'when runner is protected' do + before do + runner.protected_! + end + + context 'when build is protected' do + before do + build.protected = true + end + + it { is_expected.to be_truthy } + end + + context 'when build is unprotected' do + before do + build.protected = false + end + + it { is_expected.to be_falsey } + end + end end describe '#status' do |
