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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
278f4423
Commit
278f4423
authored
Mar 01, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve commit status API specs
parent
85a461e0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
30 deletions
+19
-30
spec/requests/api/commit_status_spec.rb
spec/requests/api/commit_status_spec.rb
+19
-30
No files found.
spec/requests/api/commit_status_spec.rb
View file @
278f4423
...
...
@@ -9,44 +9,32 @@ describe API::CommitStatus, api: true do
let
(
:guest
)
{
create_user
(
ProjectMember
::
GUEST
)
}
let
(
:reporter
)
{
create_user
(
ProjectMember
::
REPORTER
)
}
let
(
:developer
)
{
create_user
(
ProjectMember
::
DEVELOPER
)
}
let
(
:sha
)
{
commit
.
id
}
describe
"GET /projects/:id/repository/commits/:sha/statuses"
do
let
(
:get_url
)
{
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/statuses"
}
let
(
:get_url
)
{
"/projects/
#{
project
.
id
}
/repository/commits/
#{
sha
}
/statuses"
}
context
'ci commit exists'
do
let!
(
:ci_commit
)
{
project
.
ensure_ci_commit
(
commit
.
id
)
}
it_behaves_like
'a paginated resources'
do
let
(
:request
)
{
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/statuses"
,
reporter
)
}
let
(
:request
)
{
get
api
(
get_url
,
reporter
)
}
end
context
"reporter user"
do
let
(
:statuses_id
)
{
json_response
.
map
{
|
status
|
status
[
'id'
]
}
}
let!
(
:status1
)
do
create
(
:commit_status
,
commit:
ci_commit
,
status:
'running'
)
end
let!
(
:status2
)
do
create
(
:commit_status
,
commit:
ci_commit
,
name:
'coverage'
,
status:
'pending'
)
end
let!
(
:status3
)
do
create
(
:commit_status
,
commit:
ci_commit
,
name:
'coverage'
,
ref:
'develop'
,
status:
'running'
,
allow_failure:
true
)
end
let!
(
:status4
)
do
create
(
:commit_status
,
commit:
ci_commit
,
name:
'coverage'
,
status:
'success'
)
end
let!
(
:status5
)
do
create
(
:commit_status
,
commit:
ci_commit
,
ref:
'develop'
,
status:
'success'
)
def
create_status
(
opts
=
{})
create
(
:commit_status
,
{
commit:
ci_commit
}.
merge
(
opts
))
end
let!
(
:status6
)
do
create
(
:commit_status
,
commit:
ci_commit
,
status:
'success'
)
end
let!
(
:status1
)
{
create_status
(
status:
'running'
)
}
let!
(
:status2
)
{
create_status
(
name:
'coverage'
,
status:
'pending'
)
}
let!
(
:status3
)
{
create_status
(
ref:
'develop'
,
status:
'running'
,
allow_failure:
true
)
}
let!
(
:status4
)
{
create_status
(
name:
'coverage'
,
status:
'success'
)
}
let!
(
:status5
)
{
create_status
(
name:
'coverage'
,
ref:
'develop'
,
status:
'success'
)
}
let!
(
:status6
)
{
create_status
(
status:
'success'
)
}
context
'latest commit statuses'
do
before
{
get
api
(
get_url
,
reporter
)
}
...
...
@@ -68,7 +56,9 @@ describe API::CommitStatus, api: true do
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
statuses_id
).
to
contain_exactly
(
status1
.
id
,
status2
.
id
,
status3
.
id
,
status4
.
id
,
status5
.
id
,
status6
.
id
)
expect
(
statuses_id
).
to
contain_exactly
(
status1
.
id
,
status2
.
id
,
status3
.
id
,
status4
.
id
,
status5
.
id
,
status6
.
id
)
end
end
...
...
@@ -90,7 +80,7 @@ describe API::CommitStatus, api: true do
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
statuses_id
).
to
contain_exactly
(
status
3
.
id
,
status4
.
id
)
expect
(
statuses_id
).
to
contain_exactly
(
status
4
.
id
,
status5
.
id
)
end
end
end
...
...
@@ -124,7 +114,7 @@ describe API::CommitStatus, api: true do
end
describe
'POST /projects/:id/statuses/:sha'
do
let
(
:post_url
)
{
"/projects/
#{
project
.
id
}
/statuses/
#{
commit
.
id
}
"
}
let
(
:post_url
)
{
"/projects/
#{
project
.
id
}
/statuses/
#{
sha
}
"
}
context
'developer user'
do
context
'only required parameters'
do
...
...
@@ -177,9 +167,8 @@ describe API::CommitStatus, api: true do
end
context
'invalid commit'
do
before
do
post
api
(
"/projects/
#{
project
.
id
}
/statuses/invalid_sha"
,
developer
),
state:
'running'
end
let
(
:sha
)
{
'invalid_sha'
}
before
{
post
api
(
post_url
,
developer
),
state:
'running'
}
it
'returns not found error'
do
expect
(
response
.
status
).
to
eq
(
404
)
...
...
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