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
eda34b1a
Commit
eda34b1a
authored
Aug 21, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec. Fix runner setting page. It worked.
parent
e1ef436d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
5 deletions
+39
-5
app/controllers/projects/runners_controller.rb
app/controllers/projects/runners_controller.rb
+3
-1
app/views/projects/runners/_form.html.haml
app/views/projects/runners/_form.html.haml
+1
-1
db/migrate/20170816133938_add_access_level_to_ci_runners.rb
db/migrate/20170816133938_add_access_level_to_ci_runners.rb
+2
-2
lib/gitlab/ci/stage/seed.rb
lib/gitlab/ci/stage/seed.rb
+1
-1
spec/factories/ci/runners.rb
spec/factories/ci/runners.rb
+8
-0
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+24
-0
No files found.
app/controllers/projects/runners_controller.rb
View file @
eda34b1a
...
...
@@ -59,6 +59,8 @@ class Projects::RunnersController < Projects::ApplicationController
end
def
runner_params
params
.
require
(
:runner
).
permit
(
Ci
::
Runner
::
FORM_EDITABLE
)
params
.
require
(
:runner
).
permit
(
Ci
::
Runner
::
FORM_EDITABLE
).
tap
do
|
params
|
params
[
'access_level'
]
=
params
[
'access_level'
]
&
.
to_i
end
end
end
app/views/projects/runners/_form.html.haml
View file @
eda34b1a
...
...
@@ -10,7 +10,7 @@
=
label
:protected
,
"Protected"
,
class:
'control-label'
.col-sm-10
.checkbox
=
f
.
check_box
:access_level
,
1
,
0
=
f
.
check_box
:access_level
,
{},
Ci
::
Runner
.
access_levels
[
'protected_'
],
Ci
::
Runner
.
access_levels
[
'unprotected'
]
%span
.light
This runner will only run on pipelines trigged on protected branches
.form-group
=
label
:run_untagged
,
'Run untagged jobs'
,
class:
'control-label'
...
...
db/migrate/20170816133938_add_access_level_to_ci_runners.rb
View file @
eda34b1a
...
...
@@ -6,8 +6,8 @@ class AddAccessLevelToCiRunners < ActiveRecord::Migration
disable_ddl_transaction!
def
up
# Ci::Runner.unprotected: 0
add_column_with_default
(
:ci_runners
,
:access_level
,
:integer
,
default:
0
)
add_column_with_default
(
:ci_runners
,
:access_level
,
:integer
,
default:
Ci
::
Runner
.
access_levels
[
'unprotected'
]
)
end
def
down
...
...
lib/gitlab/ci/stage/seed.rb
View file @
eda34b1a
...
...
@@ -28,7 +28,7 @@ module Gitlab
attributes
.
merge
(
project:
project
,
ref:
pipeline
.
ref
,
tag:
pipeline
.
tag
,
trigger_request:
trigger
trigger_request:
trigger
,
protected:
protected
?)
end
end
...
...
spec/factories/ci/runners.rb
View file @
eda34b1a
...
...
@@ -21,5 +21,13 @@ FactoryGirl.define do
trait
:inactive
do
active
false
end
trait
:protected
do
access_level
Ci
::
Runner
.
access_levels
[
'protected_'
]
end
trait
:unprotected
do
access_level
Ci
::
Runner
.
access_levels
[
'unprotected'
]
end
end
end
spec/models/ci/runner_spec.rb
View file @
eda34b1a
...
...
@@ -456,4 +456,28 @@ 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 protected'
do
before
do
create
(
:ci_runner
,
:protected
)
end
it
'a protected runner exists'
do
expect
(
Ci
::
Runner
.
count
).
to
eq
(
1
)
expect
(
Ci
::
Runner
.
last
.
protected_?
).
to
eq
(
true
)
end
end
context
'when access_level of a runner is unprotected'
do
before
do
create
(
:ci_runner
,
:unprotected
)
end
it
'an unprotected runner exists'
do
expect
(
Ci
::
Runner
.
count
).
to
eq
(
1
)
expect
(
Ci
::
Runner
.
last
.
unprotected?
).
to
eq
(
true
)
end
end
end
end
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