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
iv
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
Show 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
context
'when runner is shared'
do
it
"should return runner's details"
do
it
"should return runner's details"
do
get
api
(
"/runners/
#{
specific
_runner
.
id
}
"
,
admin
)
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,20 +127,24 @@ describe API::API, api: true do
...
@@ -125,20 +127,24 @@ describe API::API, api: true do
end
end
context
"runner project's administrative user"
do
context
"runner project's administrative user"
do
context
'when runner is not shared'
do
it
"should return runner's details"
do
it
"should return runner's details"
do
get
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
user
)
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
it
"should return runner's details"
do
get
api
(
"/runners/
#{
shared_runner
.
id
}
"
,
user
)
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
context
'other authorized user'
do
context
'other authorized user'
do
it
"should not return runner's details"
do
it
"should not return runner's details"
do
...
@@ -159,7 +165,8 @@ describe API::API, api: true do
...
@@ -159,7 +165,8 @@ 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
it
'should update runner'
do
description
=
shared_runner
.
description
description
=
shared_runner
.
description
active
=
shared_runner
.
active
active
=
shared_runner
.
active
tag_list
=
shared_runner
.
tag_list
tag_list
=
shared_runner
.
tag_list
...
@@ -172,8 +179,10 @@ describe API::API, api: true do
...
@@ -172,8 +179,10 @@ describe API::API, api: true do
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
it
'should update runner'
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
...
@@ -182,6 +191,7 @@ describe API::API, api: true do
...
@@ -182,6 +191,7 @@ describe API::API, api: true do
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
put
api
(
'/runners/9999'
,
admin
),
description:
'test'
put
api
(
'/runners/9999'
,
admin
),
description:
'test'
...
@@ -191,19 +201,22 @@ describe API::API, api: true do
...
@@ -191,19 +201,22 @@ 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
it
'should not update runner'
do
put
api
(
"/runners/
#{
shared_runner
.
id
}
"
,
user
),
description:
'test'
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
it
'should not update runner without access to it'
do
put
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
user2
),
description:
'test'
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
...
@@ -212,7 +225,7 @@ describe API::API, api: true do
...
@@ -212,7 +225,7 @@ describe API::API, api: true do
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,26 +239,30 @@ describe API::API, api: true do
...
@@ -226,26 +239,30 @@ 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
it
'should delete runner'
do
expect
do
expect
do
delete
api
(
"/runners/
#{
shared_runner
.
id
}
"
,
admin
)
delete
api
(
"/runners/
#{
shared_runner
.
id
}
"
,
admin
)
end
.
to
change
{
Ci
::
Runner
.
shared
.
count
}.
by
(
-
1
)
end
.
to
change
{
Ci
::
Runner
.
shared
.
count
}.
by
(
-
1
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
end
end
end
it
'should delete unused specific runner'
do
context
'when runner is not shared'
do
it
'should delete unused runner'
do
expect
do
expect
do
delete
api
(
"/runners/
#{
unused_specific_runner
.
id
}
"
,
admin
)
delete
api
(
"/runners/
#{
unused_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
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
delete
api
(
'/runners/9999'
,
admin
)
delete
api
(
'/runners/9999'
,
admin
)
...
@@ -255,12 +272,15 @@ describe API::API, api: true do
...
@@ -255,12 +272,15 @@ 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
it
'should not delete runner'
do
delete
api
(
"/runners/
#{
shared_runner
.
id
}
"
,
user
)
delete
api
(
"/runners/
#{
shared_runner
.
id
}
"
,
user
)
expect
(
response
.
status
).
to
eq
(
403
)
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
it
'should not delete runner without access to it'
do
delete
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
user2
)
delete
api
(
"/runners/
#{
specific_runner
.
id
}
"
,
user2
)
expect
(
response
.
status
).
to
eq
(
403
)
expect
(
response
.
status
).
to
eq
(
403
)
end
end
...
@@ -277,6 +297,7 @@ describe API::API, api: true do
...
@@ -277,6 +297,7 @@ describe API::API, api: true do
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
end
end
end
end
end
context
'unauthorized user'
do
context
'unauthorized user'
do
it
'should not delete runner'
do
it
'should not delete runner'
do
...
@@ -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