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
dc182dc5
Commit
dc182dc5
authored
Feb 15, 2016
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some modifications to spec/requests/api/runners_spec.rb
parent
d1ac00ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
112 additions
and
88 deletions
+112
-88
spec/requests/api/runners_spec.rb
spec/requests/api/runners_spec.rb
+112
-88
No files found.
spec/requests/api/runners_spec.rb
View file @
dc182dc5
...
@@ -14,8 +14,6 @@ describe API::API, api: true do
...
@@ -14,8 +14,6 @@ describe API::API, api: true do
let!
(
:shared_runner
)
{
create
(
:ci_shared_runner
,
tag_list:
[
'mysql'
,
'ruby'
],
active:
true
)
}
let!
(
:shared_runner
)
{
create
(
:ci_shared_runner
,
tag_list:
[
'mysql'
,
'ruby'
],
active:
true
)
}
let!
(
:specific_runner
)
{
create
(
:ci_specific_runner
,
tag_list:
[
'mysql'
,
'ruby'
])
}
let!
(
:specific_runner
)
{
create
(
:ci_specific_runner
,
tag_list:
[
'mysql'
,
'ruby'
])
}
let!
(
:specific_runner_project
)
{
create
(
:ci_runner_project
,
runner:
specific_runner
,
project:
project
)
}
let!
(
:specific_runner_project
)
{
create
(
:ci_runner_project
,
runner:
specific_runner
,
project:
project
)
}
let!
(
:specific_runner2
)
{
create
(
:ci_specific_runner
)
}
let!
(
:specific_runner2_project
)
{
create
(
:ci_runner_project
,
runner:
specific_runner2
,
project:
project2
)
}
let!
(
:unused_specific_runner
)
{
create
(
:ci_specific_runner
)
}
let!
(
:unused_specific_runner
)
{
create
(
:ci_specific_runner
)
}
let!
(
:two_projects_runner
)
{
create
(
:ci_specific_runner
)
}
let!
(
:two_projects_runner
)
{
create
(
:ci_specific_runner
)
}
let!
(
:two_projects_runner_project
)
{
create
(
:ci_runner_project
,
runner:
two_projects_runner
,
project:
project
)
}
let!
(
:two_projects_runner_project
)
{
create
(
:ci_runner_project
,
runner:
two_projects_runner
,
project:
project
)
}
...
@@ -25,7 +23,7 @@ describe API::API, api: true do
...
@@ -25,7 +23,7 @@ describe API::API, api: true do
context
'authorized user'
do
context
'authorized user'
do
it
'should return user available runners'
do
it
'should return user available runners'
do
get
api
(
'/runners'
,
user
)
get
api
(
'/runners'
,
user
)
shared
=
false
||
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
shared
=
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
...
@@ -34,7 +32,7 @@ describe API::API, api: true do
...
@@ -34,7 +32,7 @@ describe API::API, api: true do
it
'should filter runners by scope'
do
it
'should filter runners by scope'
do
get
api
(
'/runners?scope=active'
,
user
)
get
api
(
'/runners?scope=active'
,
user
)
shared
=
false
||
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
shared
=
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
...
@@ -61,7 +59,7 @@ describe API::API, api: true do
...
@@ -61,7 +59,7 @@ describe API::API, api: true do
context
'with admin privileges'
do
context
'with admin privileges'
do
it
'should return all runners'
do
it
'should return all runners'
do
get
api
(
'/runners/all'
,
admin
)
get
api
(
'/runners/all'
,
admin
)
shared
=
false
||
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
shared
=
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
...
@@ -79,7 +77,7 @@ describe API::API, api: true do
...
@@ -79,7 +77,7 @@ describe API::API, api: true do
it
'should filter runners by scope'
do
it
'should filter runners by scope'
do
get
api
(
'/runners/all?scope=specific'
,
admin
)
get
api
(
'/runners/all?scope=specific'
,
admin
)
shared
=
false
||
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
shared
=
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
...
@@ -103,18 +101,22 @@ describe API::API, api: true do
...
@@ -103,18 +101,22 @@ describe API::API, api: true do
describe
'GET /runners/:id'
do
describe
'GET /runners/:id'
do
context
'admin user'
do
context
'admin user'
do
it
"should return runner's details"
do
context
'when runner is shared'
do
get
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
admin
)
it
"should return runner's details"
do
get
api
(
"/runners/
#{
shared_runner
.
id
}
"
,
admin
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
[
'description'
]).
to
eq
(
specific_runner
.
description
)
expect
(
json_response
[
'description'
]).
to
eq
(
shared_runner
.
description
)
end
end
end
it
"should return shared runner's details"
do
context
'when runner is not shared'
do
get
api
(
"/runners/
#{
shared_runner
.
id
}
"
,
admin
)
it
"should return runner's details"
do
get
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
admin
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
[
'description'
]).
to
eq
(
shared_runner
.
description
)
expect
(
json_response
[
'description'
]).
to
eq
(
specific_runner
.
description
)
end
end
end
it
'should return 404 if runner does not exists'
do
it
'should return 404 if runner does not exists'
do
...
@@ -125,18 +127,22 @@ describe API::API, api: true do
...
@@ -125,18 +127,22 @@ describe API::API, api: true do
end
end
context
"runner project's administrative user"
do
context
"runner project's administrative user"
do
it
"should return runner's details"
do
context
'when runner is not shared'
do
get
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
user
)
it
"should return runner's details"
do
get
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
[
'description'
]).
to
eq
(
specific_runner
.
description
)
expect
(
json_response
[
'description'
]).
to
eq
(
specific_runner
.
description
)
end
end
end
it
"should return shared runner's details"
do
context
'when runner is shared'
do
get
api
(
"/runners/
#{
shared_runner
.
id
}
"
,
user
)
it
"should return runner's details"
do
get
api
(
"/runners/
#{
shared_runner
.
id
}
"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
[
'description'
]).
to
eq
(
shared_runner
.
description
)
expect
(
json_response
[
'description'
]).
to
eq
(
shared_runner
.
description
)
end
end
end
end
end
...
@@ -159,28 +165,32 @@ describe API::API, api: true do
...
@@ -159,28 +165,32 @@ describe API::API, api: true do
describe
'PUT /runners/:id'
do
describe
'PUT /runners/:id'
do
context
'admin user'
do
context
'admin user'
do
it
'should update shared runner'
do
context
'when runner is shared'
do
description
=
shared_runner
.
description
it
'should update runner'
do
active
=
shared_runner
.
active
description
=
shared_runner
.
description
tag_list
=
shared_runner
.
tag_list
active
=
shared_runner
.
active
put
api
(
"/runners/
#{
shared_runner
.
id
}
"
,
admin
),
description:
"
#{
description
}
_updated"
,
active:
!
active
,
tag_list
=
shared_runner
.
tag_list
tag_list:
[
'ruby2.1'
,
'pgsql'
,
'mysql'
]
put
api
(
"/runners/
#{
shared_runner
.
id
}
"
,
admin
),
description:
"
#{
description
}
_updated"
,
active:
!
active
,
shared_runner
.
reload
tag_list:
[
'ruby2.1'
,
'pgsql'
,
'mysql'
]
shared_runner
.
reload
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
shared_runner
.
description
).
not_to
eq
(
description
)
expect
(
shared_runner
.
description
).
not_to
eq
(
description
)
expect
(
shared_runner
.
active
).
not_to
eq
(
active
)
expect
(
shared_runner
.
active
).
not_to
eq
(
active
)
expect
(
shared_runner
.
tag_list
).
not_to
eq
(
tag_list
)
expect
(
shared_runner
.
tag_list
).
not_to
eq
(
tag_list
)
end
end
end
it
'should update specific runner'
do
context
'when runner is not shared'
do
description
=
specific_runner
.
description
it
'should update runner'
do
put
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
admin
),
description:
'test'
description
=
specific_runner
.
description
specific_runner
.
reload
put
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
admin
),
description:
'test'
specific_runner
.
reload
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
specific_runner
.
description
).
to
eq
(
'test'
)
expect
(
specific_runner
.
description
).
to
eq
(
'test'
)
expect
(
specific_runner
.
description
).
not_to
eq
(
description
)
expect
(
specific_runner
.
description
).
not_to
eq
(
description
)
end
end
end
it
'should return 404 if runner does not exists'
do
it
'should return 404 if runner does not exists'
do
...
@@ -191,28 +201,31 @@ describe API::API, api: true do
...
@@ -191,28 +201,31 @@ describe API::API, api: true do
end
end
context
'authorized user'
do
context
'authorized user'
do
it
'should not update shared runner'
do
context
'when runner is shared'
do
put
api
(
"/runners/
#{
shared_runner
.
id
}
"
,
user
),
description:
'test'
it
'should not update runner'
do
put
api
(
"/runners/
#{
shared_runner
.
id
}
"
,
user
),
description:
'test'
expect
(
response
.
status
).
to
eq
(
403
)
expect
(
response
.
status
).
to
eq
(
403
)
end
end
end
it
'should not update specific runner without access to'
do
context
'when runner is not shared'
do
put
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
user2
),
description:
'test'
it
'should not update runner without access to it'
do
put
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
user2
),
description:
'test'
expect
(
response
.
status
).
to
eq
(
403
)
expect
(
response
.
status
).
to
eq
(
403
)
end
end
it
'should update specific runner
'
do
it
'should update runner with access to it
'
do
description
=
specific_runner
.
description
description
=
specific_runner
.
description
put
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
admin
),
description:
'test'
put
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
admin
),
description:
'test'
specific_runner
.
reload
specific_runner
.
reload
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
specific_runner
.
description
).
to
eq
(
'test'
)
expect
(
specific_runner
.
description
).
to
eq
(
'test'
)
expect
(
specific_runner
.
description
).
not_to
eq
(
description
)
expect
(
specific_runner
.
description
).
not_to
eq
(
description
)
end
end
end
end
end
context
'unauthorized user'
do
context
'unauthorized user'
do
...
@@ -226,25 +239,29 @@ describe API::API, api: true do
...
@@ -226,25 +239,29 @@ describe API::API, api: true do
describe
'DELETE /runners/:id'
do
describe
'DELETE /runners/:id'
do
context
'admin user'
do
context
'admin user'
do
it
'should delete shared runner'
do
context
'when runner is shared'
do
expect
do
it
'should delete runner'
do
delete
api
(
"/runners/
#{
shared_runner
.
id
}
"
,
admin
)
expect
do
end
.
to
change
{
Ci
::
Runner
.
shared
.
count
}.
by
(
-
1
)
delete
api
(
"/runners/
#{
shared_runner
.
id
}
"
,
admin
)
expect
(
response
.
status
).
to
eq
(
200
)
end
.
to
change
{
Ci
::
Runner
.
shared
.
count
}.
by
(
-
1
)
expect
(
response
.
status
).
to
eq
(
200
)
end
end
end
it
'should delete unused specific runner'
do
context
'when runner is not shared'
do
expect
do
it
'should delete unused runner'
do
delete
api
(
"/runners/
#{
unused_specific_runner
.
id
}
"
,
admin
)
expect
do
end
.
to
change
{
Ci
::
Runner
.
specific
.
count
}.
by
(
-
1
)
delete
api
(
"/runners/
#{
unused_specific_runner
.
id
}
"
,
admin
)
expect
(
response
.
status
).
to
eq
(
200
)
end
.
to
change
{
Ci
::
Runner
.
specific
.
count
}.
by
(
-
1
)
end
expect
(
response
.
status
).
to
eq
(
200
)
end
it
'should delete used specific runner'
do
it
'should delete used runner'
do
expect
do
expect
do
delete
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
admin
)
delete
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
admin
)
end
.
to
change
{
Ci
::
Runner
.
specific
.
count
}.
by
(
-
1
)
end
.
to
change
{
Ci
::
Runner
.
specific
.
count
}.
by
(
-
1
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
end
end
end
it
'should return 404 if runner does not exists'
do
it
'should return 404 if runner does not exists'
do
...
@@ -255,26 +272,30 @@ describe API::API, api: true do
...
@@ -255,26 +272,30 @@ describe API::API, api: true do
end
end
context
'authorized user'
do
context
'authorized user'
do
it
'should not delete shared runner'
do
context
'when runner is shared'
do
delete
api
(
"/runners/
#{
shared_runner
.
id
}
"
,
user
)
it
'should not delete runner'
do
expect
(
response
.
status
).
to
eq
(
403
)
delete
api
(
"/runners/
#{
shared_runner
.
id
}
"
,
user
)
expect
(
response
.
status
).
to
eq
(
403
)
end
end
end
it
'should not delete runner without access to'
do
context
'when runner is not shared'
do
delete
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
user2
)
it
'should not delete runner without access to it'
do
expect
(
response
.
status
).
to
eq
(
403
)
delete
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
user2
)
end
expect
(
response
.
status
).
to
eq
(
403
)
end
it
'should not delete runner with more than one associated project'
do
it
'should not delete runner with more than one associated project'
do
delete
api
(
"/runners/
#{
two_projects_runner
.
id
}
"
,
user
)
delete
api
(
"/runners/
#{
two_projects_runner
.
id
}
"
,
user
)
expect
(
response
.
status
).
to
eq
(
403
)
expect
(
response
.
status
).
to
eq
(
403
)
end
end
it
'should delete runner for one owned project'
do
it
'should delete runner for one owned project'
do
expect
do
expect
do
delete
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
user
)
delete
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
user
)
end
.
to
change
{
Ci
::
Runner
.
specific
.
count
}.
by
(
-
1
)
end
.
to
change
{
Ci
::
Runner
.
specific
.
count
}.
by
(
-
1
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
end
end
end
end
end
...
@@ -291,7 +312,7 @@ describe API::API, api: true do
...
@@ -291,7 +312,7 @@ describe API::API, api: true do
context
'authorized user with master privileges'
do
context
'authorized user with master privileges'
do
it
"should return project's runners"
do
it
"should return project's runners"
do
get
api
(
"/projects/
#{
project
.
id
}
/runners"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/runners"
,
user
)
shared
=
false
||
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
shared
=
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
...
@@ -317,6 +338,9 @@ describe API::API, api: true do
...
@@ -317,6 +338,9 @@ describe API::API, api: true do
end
end
describe
'POST /projects/:id/runners/:runner_id'
do
describe
'POST /projects/:id/runners/:runner_id'
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
context
'authorized user'
do
it
'should enable specific runner'
do
it
'should enable specific runner'
do
expect
do
expect
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