summaryrefslogtreecommitdiff
path: root/spec/services/ci
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-08-22 17:01:11 +0900
committerShinya Maeda <shinya@gitlab.com>2017-09-03 23:49:10 +0900
commitbbe967abeba7be1db79e34439e74cd113c240b52 (patch)
treeb498f626149dc0e8ed541352fa9080e10a99fb34 /spec/services/ci
parenteda34b1a1846a5d5b55cc127a32b0c7628580f25 (diff)
downloadgitlab-ce-bbe967abeba7be1db79e34439e74cd113c240b52.tar.gz
Add the rest of specs
Diffstat (limited to 'spec/services/ci')
-rw-r--r--spec/services/ci/register_job_service_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/services/ci/register_job_service_spec.rb b/spec/services/ci/register_job_service_spec.rb
index 8eb0d2d10a4..99f2507e59c 100644
--- a/spec/services/ci/register_job_service_spec.rb
+++ b/spec/services/ci/register_job_service_spec.rb
@@ -215,6 +215,44 @@ module Ci
end
end
+ context 'when a runner is unprotected' do
+ context 'when a job is protected' do
+ let!(:pending_build) { create(:ci_build, :protected, pipeline: pipeline) }
+
+ it 'picks the protected job' do
+ expect(execute(specific_runner)).to eq(pending_build)
+ end
+ end
+
+ context 'when a job is unprotected' do
+ let!(:pending_build) { create(:ci_build, :unprotected, pipeline: pipeline) }
+
+ it 'picks the unprotected job' do
+ expect(execute(specific_runner)).to eq(pending_build)
+ end
+ end
+ end
+
+ context 'when a runner is protected' do
+ let!(:specific_runner) { create(:ci_runner, :protected, :specific) }
+
+ context 'when a job is protected' do
+ let!(:pending_build) { create(:ci_build, :protected, pipeline: pipeline) }
+
+ it 'picks the protected job' do
+ expect(execute(specific_runner)).to eq(pending_build)
+ end
+ end
+
+ context 'when a job is unprotected' do
+ let!(:unprotected_job) { create(:ci_build, :unprotected, pipeline: pipeline) }
+
+ it 'does not pick the unprotected job' do
+ expect(execute(specific_runner)).to be_nil
+ end
+ end
+ end
+
def execute(runner)
described_class.new(runner).execute.build
end