Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
07f7a01b
Commit
07f7a01b
authored
Aug 31, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve spec. Add validation for accel_level on runner.
parent
d3bf0160
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
33 deletions
+54
-33
app/models/ci/runner.rb
app/models/ci/runner.rb
+1
-0
spec/factories/ci/runners.rb
spec/factories/ci/runners.rb
+2
-2
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+17
-5
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+30
-24
spec/services/ci/register_job_service_spec.rb
spec/services/ci/register_job_service_spec.rb
+4
-2
No files found.
app/models/ci/runner.rb
View file @
07f7a01b
...
...
@@ -35,6 +35,7 @@ module Ci
end
validate
:tag_constraints
validates
:access_level
,
presence:
true
acts_as_taggable
...
...
spec/factories/ci/runners.rb
View file @
07f7a01b
...
...
@@ -23,11 +23,11 @@ FactoryGirl.define do
end
trait
:ref_protected
do
access_level
'ref_protected'
access_level
:ref_protected
end
trait
:not_protected
do
access_level
'not_protected'
access_level
:not_protected
end
end
end
spec/models/ci/build_spec.rb
View file @
07f7a01b
...
...
@@ -44,13 +44,25 @@ describe Ci::Build do
end
describe
'.ref_protected'
do
let!
(
:protected_job
)
{
create
(
:ci_build
,
:protected
)
}
let!
(
:unprotected_job
)
{
create
(
:ci_build
,
:unprotected
)
}
subject
{
described_class
.
ref_protected
}
it
{
is_expected
.
to
include
(
protected_job
)
}
it
{
is_expected
.
not_to
include
(
unprotected_job
)
}
context
'when protected is true'
do
let!
(
:job
)
{
create
(
:ci_build
,
:protected
)
}
it
{
is_expected
.
to
include
(
job
)
}
end
context
'when protected is false'
do
let!
(
:job
)
{
create
(
:ci_build
,
:unprotected
)
}
it
{
is_expected
.
not_to
include
(
job
)
}
end
context
'when protected is false'
do
let!
(
:job
)
{
create
(
:ci_build
,
protected:
nil
)
}
it
{
is_expected
.
not_to
include
(
job
)
}
end
end
describe
'#actionize'
do
...
...
spec/models/ci/runner_spec.rb
View file @
07f7a01b
...
...
@@ -2,6 +2,8 @@ require 'spec_helper'
describe
Ci
::
Runner
do
describe
'validation'
do
it
{
is_expected
.
to
validate_presence_of
(
:access_level
)
}
context
'when runner is not allowed to pick untagged jobs'
do
context
'when runner does not have tags'
do
it
'is not valid'
do
...
...
@@ -19,6 +21,34 @@ describe Ci::Runner do
end
end
describe
'#access_level'
do
context
'when creating new runner and access_level is nil'
do
let
(
:runner
)
do
build
(
:ci_runner
,
access_level:
nil
)
end
it
"object is invalid"
do
expect
(
runner
).
not_to
be_valid
end
end
context
'when creating new runner and access_level is defined in enum'
do
let
(
:runner
)
do
build
(
:ci_runner
,
access_level: :not_protected
)
end
it
"object is valid"
do
expect
(
runner
).
to
be_valid
end
end
context
'when creating new runner and access_level is not defined in enum'
do
it
"raises an error"
do
expect
{
build
(
:ci_runner
,
access_level: :this_is_not_defined
)
}.
to
raise_error
(
ArgumentError
)
end
end
end
describe
'#display_name'
do
it
'returns the description if it has a value'
do
runner
=
FactoryGirl
.
build
(
:ci_runner
,
description:
'Linux/Ruby-1.9.3-p448'
)
...
...
@@ -480,28 +510,4 @@ describe Ci::Runner do
expect
(
described_class
.
search
(
runner
.
description
.
upcase
)).
to
eq
([
runner
])
end
end
describe
'.access_level'
do
context
'when access_level of a runner is ref_protected'
do
before
do
create
(
:ci_runner
,
:ref_protected
)
end
it
'a protected runner exists'
do
expect
(
described_class
.
count
).
to
eq
(
1
)
expect
(
described_class
.
last
.
ref_protected?
).
to
eq
(
true
)
end
end
context
'when access_level of a runner is not_protected'
do
before
do
create
(
:ci_runner
,
:not_protected
)
end
it
'an not_protected runner exists'
do
expect
(
described_class
.
count
).
to
eq
(
1
)
expect
(
described_class
.
last
.
not_protected?
).
to
eq
(
true
)
end
end
end
end
spec/services/ci/register_job_service_spec.rb
View file @
07f7a01b
...
...
@@ -215,7 +215,9 @@ module Ci
end
end
context
'when a runner is not_protected'
do
context
'when access_level of runner is not_protected'
do
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:not_protected
,
:specific
)
}
context
'when a job is protected'
do
let!
(
:pending_build
)
{
create
(
:ci_build
,
:protected
,
pipeline:
pipeline
)
}
...
...
@@ -233,7 +235,7 @@ module Ci
end
end
context
'when a runner is ref_protected'
do
context
'when a
ccess_level of
runner is ref_protected'
do
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:ref_protected
,
:specific
)
}
context
'when a job is protected'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment