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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
5328f7d1
Commit
5328f7d1
authored
Sep 05, 2018
by
Steve Azzopardi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add runner JSON schema
closes
https://gitlab.com/gitlab-org/gitlab-ce/issues/51093
parent
cdc4cd09
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
3 deletions
+83
-3
app/serializers/runner_entity.rb
app/serializers/runner_entity.rb
+5
-2
spec/controllers/projects/jobs_controller_spec.rb
spec/controllers/projects/jobs_controller_spec.rb
+59
-0
spec/fixtures/api/schemas/job/job_details.json
spec/fixtures/api/schemas/job/job_details.json
+2
-1
spec/fixtures/api/schemas/job/runner.json
spec/fixtures/api/schemas/job/runner.json
+17
-0
No files found.
app/serializers/runner_entity.rb
View file @
5328f7d1
...
@@ -5,8 +5,7 @@ class RunnerEntity < Grape::Entity
...
@@ -5,8 +5,7 @@ class RunnerEntity < Grape::Entity
expose
:id
,
:description
expose
:id
,
:description
expose
:edit_path
,
expose
:edit_path
,
if:
->
(
*
)
{
can_edit_runner?
}
do
|
runner
|
if:
->
(
*
)
{
can?
(
request
.
current_user
,
:admin_build
,
project
)
&&
runner
.
project_type?
}
do
|
runner
|
edit_project_runner_path
(
project
,
runner
)
edit_project_runner_path
(
project
,
runner
)
end
end
...
@@ -17,4 +16,8 @@ class RunnerEntity < Grape::Entity
...
@@ -17,4 +16,8 @@ class RunnerEntity < Grape::Entity
def
project
def
project
request
.
project
request
.
project
end
end
def
can_edit_runner?
can?
(
request
.
current_user
,
:update_runner
,
runner
)
&&
runner
.
project_type?
end
end
end
spec/controllers/projects/jobs_controller_spec.rb
View file @
5328f7d1
...
@@ -229,6 +229,65 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -229,6 +229,65 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
expect
(
json_response
[
'deployment_status'
][
"environment"
]).
not_to
be_nil
expect
(
json_response
[
'deployment_status'
][
"environment"
]).
not_to
be_nil
end
end
end
end
context
'when user can edit runner'
do
context
'that belongs to the project'
do
let
(
:runner
)
{
create
(
:ci_runner
,
:project
,
projects:
[
project
])
}
let
(
:job
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
runner:
runner
)
}
before
do
project
.
add_maintainer
(
user
)
sign_in
(
user
)
get_show
(
id:
job
.
id
,
format: :json
)
end
it
'user can edit runner'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'runner'
]).
to
have_key
(
'edit_path'
)
end
end
context
'that belongs to group'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:runner
)
{
create
(
:ci_runner
,
:group
,
groups:
[
group
])
}
let
(
:job
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
runner:
runner
)
}
let
(
:user
)
{
create
(
:user
,
:admin
)
}
before
do
project
.
add_maintainer
(
user
)
sign_in
(
user
)
get_show
(
id:
job
.
id
,
format: :json
)
end
it
'user can not edit runner'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'runner'
]).
not_to
have_key
(
'edit_path'
)
end
end
context
'that belongs to instance'
do
let
(
:runner
)
{
create
(
:ci_runner
,
:instance
)
}
let
(
:job
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
runner:
runner
)
}
let
(
:user
)
{
create
(
:user
,
:admin
)
}
before
do
project
.
add_maintainer
(
user
)
sign_in
(
user
)
get_show
(
id:
job
.
id
,
format: :json
)
end
it
'user can not edit runner'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'runner'
]).
not_to
have_key
(
'edit_path'
)
end
end
end
end
end
context
'when requesting JSON job is triggered'
do
context
'when requesting JSON job is triggered'
do
...
...
spec/fixtures/api/schemas/job/job_details.json
View file @
5328f7d1
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
"artifact"
:
{
"$ref"
:
"artifact.json"
},
"artifact"
:
{
"$ref"
:
"artifact.json"
},
"terminal_path"
:
{
"type"
:
"string"
},
"terminal_path"
:
{
"type"
:
"string"
},
"trigger"
:
{
"$ref"
:
"trigger.json"
},
"trigger"
:
{
"$ref"
:
"trigger.json"
},
"deployment_status"
:
{
"$ref"
:
"deployment_status.json"
}
"deployment_status"
:
{
"$ref"
:
"deployment_status.json"
},
"runner"
:
{
"$ref"
:
"runner.json"
}
}
}
}
}
spec/fixtures/api/schemas/job/runner.json
0 → 100644
View file @
5328f7d1
{
"oneOf"
:
[
{
"type"
:
"null"
},
{
"type"
:
"object"
,
"required"
:
[
"id"
,
"description"
],
"properties"
:
{
"id"
:
{
"type"
:
"integer"
},
"description"
:
{
"type"
:
"string"
},
"edit_path"
:
{
"type"
:
"string"
}
}
}
]
}
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