BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
b36116f9
Commit
b36116f9
authored
Feb 16, 2016
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move :runner_id param to POST body when enabling specific runner in project
parent
dc182dc5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
9 deletions
+17
-9
runners.rb
lib/api/runners.rb
+3
-1
runners_spec.rb
spec/requests/api/runners_spec.rb
+14
-8
No files found.
lib/api/runners.rb
View file @
b36116f9
...
...
@@ -91,7 +91,9 @@ module API
# runner_id (required) - The ID of the runner
# Example Request:
# POST /projects/:id/runners/:runner_id
post
':id/runners/:runner_id'
do
post
':id/runners'
do
required_attributes!
[
:runner_id
]
runner
=
get_runner
(
params
[
:runner_id
])
authenticate_enable_runner!
(
runner
)
Ci
::
RunnerProject
.
create
(
runner:
runner
,
project:
user_project
)
...
...
spec/requests/api/runners_spec.rb
View file @
b36116f9
...
...
@@ -337,27 +337,27 @@ describe API::API, api: true do
end
end
describe
'POST /projects/:id/runners
/:runner_id
'
do
describe
'POST /projects/:id/runners'
do
let!
(
:specific_runner2
)
{
create
(
:ci_specific_runner
)
}
let!
(
:specific_runner2_project
)
{
create
(
:ci_runner_project
,
runner:
specific_runner2
,
project:
project2
)
}
context
'authorized user'
do
it
'should enable specific runner'
do
expect
do
post
api
(
"/projects/
#{
project
.
id
}
/runners
/
#{
specific_runner2
.
id
}
"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/runners
"
,
user
),
runner_id:
specific_runner2
.
id
end
.
to
change
{
project
.
runners
.
count
}.
by
(
+
1
)
expect
(
response
.
status
).
to
eq
(
201
)
end
it
'should avoid changes when enabling already enabled runner'
do
expect
do
post
api
(
"/projects/
#{
project
.
id
}
/runners
/
#{
specific_runner
.
id
}
"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/runners
"
,
user
),
runner_id:
specific_runner
.
id
end
.
to
change
{
project
.
runners
.
count
}.
by
(
0
)
expect
(
response
.
status
).
to
eq
(
201
)
end
it
'should not enable shared runner'
do
post
api
(
"/projects/
#{
project
.
id
}
/runners
/
#{
shared_runner
.
id
}
"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/runners
"
,
user
),
runner_id:
shared_runner
.
id
expect
(
response
.
status
).
to
eq
(
403
)
end
...
...
@@ -365,7 +365,7 @@ describe API::API, api: true do
context
'user is admin'
do
it
'should enable any specific runner'
do
expect
do
post
api
(
"/projects/
#{
project
.
id
}
/runners
/
#{
unused_specific_runner
.
id
}
"
,
admin
)
post
api
(
"/projects/
#{
project
.
id
}
/runners
"
,
admin
),
runner_id:
unused_specific_runner
.
id
end
.
to
change
{
project
.
runners
.
count
}.
by
(
+
1
)
expect
(
response
.
status
).
to
eq
(
201
)
end
...
...
@@ -373,16 +373,22 @@ describe API::API, api: true do
context
'user is not admin'
do
it
'should not enable runner without access to'
do
post
api
(
"/projects/
#{
project
.
id
}
/runners
/
#{
unused_specific_runner
.
id
}
"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/runners
"
,
user
),
runner_id:
unused_specific_runner
.
id
expect
(
response
.
status
).
to
eq
(
403
)
end
end
it
'should raise an error when no runner_id param is provided'
do
post
api
(
"/projects/
#{
project
.
id
}
/runners"
,
admin
)
expect
(
response
.
status
).
to
eq
(
400
)
end
end
context
'authorized user without permissions'
do
it
'should not enable runner'
do
post
api
(
"/projects/
#{
project
.
id
}
/runners
/
#{
specific_runner2
.
id
}
"
,
user2
)
post
api
(
"/projects/
#{
project
.
id
}
/runners
"
,
user2
),
runner_id:
specific_runner2
.
id
expect
(
response
.
status
).
to
eq
(
403
)
end
...
...
@@ -390,7 +396,7 @@ describe API::API, api: true do
context
'unauthorized user'
do
it
'should not enable runner'
do
post
api
(
"/projects/
#{
project
.
id
}
/runners
/
#{
specific_runner2
.
id
}
"
)
post
api
(
"/projects/
#{
project
.
id
}
/runners
"
),
runner_id:
specific_runner2
.
id
expect
(
response
.
status
).
to
eq
(
401
)
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