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
311f4076
Commit
311f4076
authored
Feb 06, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix commit status tests
parent
08064767
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
18 deletions
+30
-18
commit_status_spec.rb
spec/requests/api/commit_status_spec.rb
+30
-18
No files found.
spec/requests/api/commit_status_spec.rb
View file @
311f4076
...
...
@@ -2,18 +2,17 @@ require 'spec_helper'
describe
API
::
CommitStatus
,
api:
true
do
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
)
}
let!
(
:reporter
)
{
create
(
:project_member
,
user:
user
,
project:
project
,
access_level:
ProjectMember
::
REPORTER
)
}
let!
(
:guest
)
{
create
(
:project_member
,
user:
user2
,
project:
project
,
access_level:
ProjectMember
::
GUEST
)
}
let!
(
:project
)
{
create
(
:project
)
}
let
(
:commit
)
{
project
.
repository
.
commit
}
let!
(
:ci_commit
)
{
project
.
ensure_ci_commit
(
commit
.
id
)
}
let
(
:commit_status
)
{
create
(
:commit_status
,
commit:
ci_commit
)
}
let
(
:guest
)
{
create_user
(
ProjectMember
::
GUEST
)
}
let
(
:reporter
)
{
create_user
(
ProjectMember
::
REPORTER
)
}
let
(
:developer
)
{
create_user
(
ProjectMember
::
DEVELOPER
)
}
describe
"GET /projects/:id/repository/commits/:sha/statuses"
do
it_behaves_like
'a paginated resources'
do
let
(
:request
)
{
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/statuses"
,
us
er
)
}
let
(
:request
)
{
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/statuses"
,
report
er
)
}
end
context
"reporter user"
do
...
...
@@ -29,7 +28,7 @@ describe API::CommitStatus, api: true do
end
it
"should return latest commit statuses"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/statuses"
,
us
er
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/statuses"
,
report
er
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
...
...
@@ -39,7 +38,7 @@ describe API::CommitStatus, api: true do
end
it
"should return all commit statuses"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/statuses?all=1"
,
us
er
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/statuses?all=1"
,
report
er
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
...
...
@@ -47,7 +46,7 @@ describe API::CommitStatus, api: true do
end
it
"should return latest commit statuses for specific ref"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/statuses?ref=develop"
,
us
er
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/statuses?ref=develop"
,
report
er
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
...
...
@@ -55,7 +54,7 @@ describe API::CommitStatus, api: true do
end
it
"should return latest commit statuses for specific name"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/statuses?name=coverage"
,
us
er
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/statuses?name=coverage"
,
report
er
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
...
...
@@ -65,7 +64,7 @@ describe API::CommitStatus, api: true do
context
"guest user"
do
it
"should not return project commits"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/statuses"
,
user2
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/statuses"
,
guest
)
expect
(
response
.
status
).
to
eq
(
403
)
end
end
...
...
@@ -81,10 +80,10 @@ describe API::CommitStatus, api: true do
describe
'POST /projects/:id/statuses/:sha'
do
let
(
:post_url
)
{
"/projects/
#{
project
.
id
}
/statuses/
#{
commit
.
id
}
"
}
context
'
report
er user'
do
context
'
develop
er user'
do
context
'should create commit status'
do
it
'with only required parameters'
do
post
api
(
post_url
,
us
er
),
state:
'success'
post
api
(
post_url
,
develop
er
),
state:
'success'
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
json_response
[
'sha'
]).
to
eq
(
commit
.
id
)
expect
(
json_response
[
'status'
]).
to
eq
(
'success'
)
...
...
@@ -95,7 +94,7 @@ describe API::CommitStatus, api: true do
end
it
'with all optional parameters'
do
post
api
(
post_url
,
us
er
),
state:
'success'
,
context:
'coverage'
,
ref:
'develop'
,
target_url:
'url'
,
description:
'test'
post
api
(
post_url
,
develop
er
),
state:
'success'
,
context:
'coverage'
,
ref:
'develop'
,
target_url:
'url'
,
description:
'test'
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
json_response
[
'sha'
]).
to
eq
(
commit
.
id
)
expect
(
json_response
[
'status'
]).
to
eq
(
'success'
)
...
...
@@ -108,25 +107,32 @@ describe API::CommitStatus, api: true do
context
'should not create commit status'
do
it
'with invalid state'
do
post
api
(
post_url
,
us
er
),
state:
'invalid'
post
api
(
post_url
,
develop
er
),
state:
'invalid'
expect
(
response
.
status
).
to
eq
(
400
)
end
it
'without state'
do
post
api
(
post_url
,
us
er
)
post
api
(
post_url
,
develop
er
)
expect
(
response
.
status
).
to
eq
(
400
)
end
it
'invalid commit'
do
post
api
(
"/projects/
#{
project
.
id
}
/statuses/invalid_sha"
,
us
er
),
state:
'running'
post
api
(
"/projects/
#{
project
.
id
}
/statuses/invalid_sha"
,
develop
er
),
state:
'running'
expect
(
response
.
status
).
to
eq
(
404
)
end
end
end
context
'reporter user'
do
it
'should not create commit status'
do
post
api
(
post_url
,
reporter
)
expect
(
response
.
status
).
to
eq
(
403
)
end
end
context
'guest user'
do
it
'should not create commit status'
do
post
api
(
post_url
,
user2
)
post
api
(
post_url
,
guest
)
expect
(
response
.
status
).
to
eq
(
403
)
end
end
...
...
@@ -138,4 +144,10 @@ describe API::CommitStatus, api: true do
end
end
end
def
create_user
(
access_level
)
user
=
create
(
:user
)
create
(
:project_member
,
user:
user
,
project:
project
,
access_level:
access_level
)
user
end
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