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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
ad35e902
Commit
ad35e902
authored
Feb 13, 2020
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add http status cop to api specs a-f
243 files inspected, 427 offenses detected, 427 offenses corrected
parent
253a09fc
Changes
27
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
429 additions
and
427 deletions
+429
-427
.rubocop.yml
.rubocop.yml
+2
-0
ee/spec/requests/api/audit_events_spec.rb
ee/spec/requests/api/audit_events_spec.rb
+2
-2
ee/spec/requests/api/branches_spec.rb
ee/spec/requests/api/branches_spec.rb
+1
-1
ee/spec/requests/api/dependencies_spec.rb
ee/spec/requests/api/dependencies_spec.rb
+3
-3
ee/spec/requests/api/deployments_spec.rb
ee/spec/requests/api/deployments_spec.rb
+8
-8
ee/spec/requests/api/elasticsearch_indexed_namespaces_spec.rb
...pec/requests/api/elasticsearch_indexed_namespaces_spec.rb
+4
-4
ee/spec/requests/api/epic_issues_spec.rb
ee/spec/requests/api/epic_issues_spec.rb
+22
-22
ee/spec/requests/api/epic_links_spec.rb
ee/spec/requests/api/epic_links_spec.rb
+14
-14
ee/spec/requests/api/epics_spec.rb
ee/spec/requests/api/epics_spec.rb
+14
-14
spec/requests/api/access_requests_spec.rb
spec/requests/api/access_requests_spec.rb
+14
-14
spec/requests/api/appearance_spec.rb
spec/requests/api/appearance_spec.rb
+10
-10
spec/requests/api/applications_spec.rb
spec/requests/api/applications_spec.rb
+15
-15
spec/requests/api/award_emoji_spec.rb
spec/requests/api/award_emoji_spec.rb
+25
-25
spec/requests/api/badges_spec.rb
spec/requests/api/badges_spec.rb
+19
-19
spec/requests/api/boards_spec.rb
spec/requests/api/boards_spec.rb
+3
-3
spec/requests/api/branches_spec.rb
spec/requests/api/branches_spec.rb
+23
-23
spec/requests/api/broadcast_messages_spec.rb
spec/requests/api/broadcast_messages_spec.rb
+22
-22
spec/requests/api/commit_statuses_spec.rb
spec/requests/api/commit_statuses_spec.rb
+24
-24
spec/requests/api/commits_spec.rb
spec/requests/api/commits_spec.rb
+55
-55
spec/requests/api/deploy_keys_spec.rb
spec/requests/api/deploy_keys_spec.rb
+25
-25
spec/requests/api/deployments_spec.rb
spec/requests/api/deployments_spec.rb
+19
-19
spec/requests/api/discussions_spec.rb
spec/requests/api/discussions_spec.rb
+1
-1
spec/requests/api/doorkeeper_access_spec.rb
spec/requests/api/doorkeeper_access_spec.rb
+4
-4
spec/requests/api/environments_spec.rb
spec/requests/api/environments_spec.rb
+23
-23
spec/requests/api/events_spec.rb
spec/requests/api/events_spec.rb
+12
-12
spec/requests/api/features_spec.rb
spec/requests/api/features_spec.rb
+25
-25
spec/requests/api/files_spec.rb
spec/requests/api/files_spec.rb
+40
-40
No files found.
.rubocop.yml
View file @
ad35e902
...
@@ -349,6 +349,8 @@ RSpec/HaveGitlabHttpStatus:
...
@@ -349,6 +349,8 @@ RSpec/HaveGitlabHttpStatus:
-
'
ee/spec/requests/{groups,projects,repositories}/**/*'
-
'
ee/spec/requests/{groups,projects,repositories}/**/*'
-
'
spec/requests/api/*/**/*.rb'
-
'
spec/requests/api/*/**/*.rb'
-
'
ee/spec/requests/api/*/**/*.rb'
-
'
ee/spec/requests/api/*/**/*.rb'
-
'
spec/requests/api/[a-f]*.rb'
-
'
ee/spec/requests/api/[a-f]*.rb'
Style/MultilineWhenThen
:
Style/MultilineWhenThen
:
Enabled
:
false
Enabled
:
false
...
...
ee/spec/requests/api/audit_events_spec.rb
View file @
ad35e902
...
@@ -35,7 +35,7 @@ describe API::AuditEvents do
...
@@ -35,7 +35,7 @@ describe API::AuditEvents do
it
'returns 200 response'
do
it
'returns 200 response'
do
get
api
(
url
,
admin
)
get
api
(
url
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'includes the correct pagination headers'
do
it
'includes the correct pagination headers'
do
...
@@ -147,7 +147,7 @@ describe API::AuditEvents do
...
@@ -147,7 +147,7 @@ describe API::AuditEvents do
it
'returns 200 response'
do
it
'returns 200 response'
do
get
api
(
url
,
admin
)
get
api
(
url
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
context
'attributes'
do
context
'attributes'
do
...
...
ee/spec/requests/api/branches_spec.rb
View file @
ad35e902
...
@@ -24,7 +24,7 @@ describe API::Branches do
...
@@ -24,7 +24,7 @@ describe API::Branches do
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
protected_branch
.
name
}
/protect"
,
user
),
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
protected_branch
.
name
}
/protect"
,
user
),
params:
{
developers_can_push:
true
,
developers_can_merge:
true
}
params:
{
developers_can_push:
true
,
developers_can_merge:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'name'
]).
to
eq
(
protected_branch
.
name
)
expect
(
json_response
[
'name'
]).
to
eq
(
protected_branch
.
name
)
expect
(
protected_branch
.
reload
.
push_access_levels
.
pluck
(
:access_level
)).
to
include
(
Gitlab
::
Access
::
NO_ACCESS
)
expect
(
protected_branch
.
reload
.
push_access_levels
.
pluck
(
:access_level
)).
to
include
(
Gitlab
::
Access
::
NO_ACCESS
)
end
end
...
...
ee/spec/requests/api/dependencies_spec.rb
View file @
ad35e902
...
@@ -25,7 +25,7 @@ describe API::Dependencies do
...
@@ -25,7 +25,7 @@ describe API::Dependencies do
end
end
it
'returns all dependencies'
do
it
'returns all dependencies'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/dependencies'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/dependencies'
,
dir:
'ee'
)
expect
(
json_response
.
length
).
to
eq
(
21
)
expect
(
json_response
.
length
).
to
eq
(
21
)
...
@@ -75,7 +75,7 @@ describe API::Dependencies do
...
@@ -75,7 +75,7 @@ describe API::Dependencies do
end
end
it
'responds with 403 Forbidden'
do
it
'responds with 403 Forbidden'
do
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -87,7 +87,7 @@ describe API::Dependencies do
...
@@ -87,7 +87,7 @@ describe API::Dependencies do
end
end
it
'responds with 404 Not Found'
do
it
'responds with 404 Not Found'
do
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
...
ee/spec/requests/api/deployments_spec.rb
View file @
ad35e902
...
@@ -36,7 +36,7 @@ describe API::Deployments do
...
@@ -36,7 +36,7 @@ describe API::Deployments do
}
}
)
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
it
'creates the deployment when the user is a maintainer'
do
it
'creates the deployment when the user is a maintainer'
do
...
@@ -53,7 +53,7 @@ describe API::Deployments do
...
@@ -53,7 +53,7 @@ describe API::Deployments do
}
}
)
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
end
end
end
end
...
@@ -81,7 +81,7 @@ describe API::Deployments do
...
@@ -81,7 +81,7 @@ describe API::Deployments do
}
}
)
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
it
'creates the deployment when the user is a developer'
do
it
'creates the deployment when the user is a developer'
do
...
@@ -98,7 +98,7 @@ describe API::Deployments do
...
@@ -98,7 +98,7 @@ describe API::Deployments do
}
}
)
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
end
end
end
end
end
end
...
@@ -132,7 +132,7 @@ describe API::Deployments do
...
@@ -132,7 +132,7 @@ describe API::Deployments do
params:
{
status:
'success'
}
params:
{
status:
'success'
}
)
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
it
'updates the deployment when the user is a maintainer'
do
it
'updates the deployment when the user is a maintainer'
do
...
@@ -143,7 +143,7 @@ describe API::Deployments do
...
@@ -143,7 +143,7 @@ describe API::Deployments do
params:
{
status:
'success'
}
params:
{
status:
'success'
}
)
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
...
@@ -165,7 +165,7 @@ describe API::Deployments do
...
@@ -165,7 +165,7 @@ describe API::Deployments do
params:
{
status:
'success'
}
params:
{
status:
'success'
}
)
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
it
'updates the deployment when the user is a developer'
do
it
'updates the deployment when the user is a developer'
do
...
@@ -176,7 +176,7 @@ describe API::Deployments do
...
@@ -176,7 +176,7 @@ describe API::Deployments do
params:
{
status:
'success'
}
params:
{
status:
'success'
}
)
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
end
end
...
...
ee/spec/requests/api/elasticsearch_indexed_namespaces_spec.rb
View file @
ad35e902
...
@@ -21,14 +21,14 @@ describe API::ElasticsearchIndexedNamespaces do
...
@@ -21,14 +21,14 @@ describe API::ElasticsearchIndexedNamespaces do
with_them
do
with_them
do
it
'errs'
do
it
'errs'
do
put
api
(
path
,
admin
),
params:
{
plan:
plan
,
percentage:
percentage
}
put
api
(
path
,
admin
),
params:
{
plan:
plan
,
percentage:
percentage
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
end
end
it
'prohibits non-admin'
do
it
'prohibits non-admin'
do
put
api
(
path
,
non_admin
),
params:
{
plan:
'gold'
,
percentage:
50
}
put
api
(
path
,
non_admin
),
params:
{
plan:
'gold'
,
percentage:
50
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -42,7 +42,7 @@ describe API::ElasticsearchIndexedNamespaces do
...
@@ -42,7 +42,7 @@ describe API::ElasticsearchIndexedNamespaces do
put
api
(
path
,
admin
),
params:
{
plan:
'gold'
,
percentage:
50
}
put
api
(
path
,
admin
),
params:
{
plan:
'gold'
,
percentage:
50
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
...
@@ -56,7 +56,7 @@ describe API::ElasticsearchIndexedNamespaces do
...
@@ -56,7 +56,7 @@ describe API::ElasticsearchIndexedNamespaces do
put
api
(
path
,
admin
),
params:
{
plan:
'gold'
,
percentage:
50
}
put
api
(
path
,
admin
),
params:
{
plan:
'gold'
,
percentage:
50
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
end
end
ee/spec/requests/api/epic_issues_spec.rb
View file @
ad35e902
...
@@ -17,7 +17,7 @@ describe API::EpicIssues do
...
@@ -17,7 +17,7 @@ describe API::EpicIssues do
get
api
(
url
,
user
)
get
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -30,7 +30,7 @@ describe API::EpicIssues do
...
@@ -30,7 +30,7 @@ describe API::EpicIssues do
it
'returns 401 unauthorized error for non authenticated user'
do
it
'returns 401 unauthorized error for non authenticated user'
do
get
api
(
url
)
get
api
(
url
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
it
'returns 404 not found error for a user without permissions to see the group'
do
it
'returns 404 not found error for a user without permissions to see the group'
do
...
@@ -39,7 +39,7 @@ describe API::EpicIssues do
...
@@ -39,7 +39,7 @@ describe API::EpicIssues do
get
api
(
url
,
user
)
get
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -53,7 +53,7 @@ describe API::EpicIssues do
...
@@ -53,7 +53,7 @@ describe API::EpicIssues do
end
end
it
'returns 200 status'
do
it
'returns 200 status'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'matches the response schema'
do
it
'matches the response schema'
do
...
@@ -73,7 +73,7 @@ describe API::EpicIssues do
...
@@ -73,7 +73,7 @@ describe API::EpicIssues do
post
api
(
url
,
user
)
post
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -86,7 +86,7 @@ describe API::EpicIssues do
...
@@ -86,7 +86,7 @@ describe API::EpicIssues do
it
'returns 401 unauthorized error for non authenticated user'
do
it
'returns 401 unauthorized error for non authenticated user'
do
post
api
(
url
)
post
api
(
url
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
it
'returns 404 not found error for a user without permissions to see the group'
do
it
'returns 404 not found error for a user without permissions to see the group'
do
...
@@ -95,13 +95,13 @@ describe API::EpicIssues do
...
@@ -95,13 +95,13 @@ describe API::EpicIssues do
post
api
(
url
,
user
)
post
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
'returns 403 forbidden error for a user without permissions to admin the epic'
do
it
'returns 403 forbidden error for a user without permissions to admin the epic'
do
post
api
(
url
,
user
)
post
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
context
'when issue project is not under the epic group'
do
context
'when issue project is not under the epic group'
do
...
@@ -116,7 +116,7 @@ describe API::EpicIssues do
...
@@ -116,7 +116,7 @@ describe API::EpicIssues do
it
'returns an error'
do
it
'returns an error'
do
post
api
(
url
,
user
)
post
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
json_response
).
to
eq
(
'message'
=>
'No Issue found for given params'
)
expect
(
json_response
).
to
eq
(
'message'
=>
'No Issue found for given params'
)
end
end
end
end
...
@@ -130,7 +130,7 @@ describe API::EpicIssues do
...
@@ -130,7 +130,7 @@ describe API::EpicIssues do
end
end
it
'returns 201 status'
do
it
'returns 201 status'
do
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
end
end
it
'matches the response schema'
do
it
'matches the response schema'
do
...
@@ -158,7 +158,7 @@ describe API::EpicIssues do
...
@@ -158,7 +158,7 @@ describe API::EpicIssues do
post
api
(
url
,
user
)
post
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -171,7 +171,7 @@ describe API::EpicIssues do
...
@@ -171,7 +171,7 @@ describe API::EpicIssues do
it
'returns 401 unauthorized error for non authenticated user'
do
it
'returns 401 unauthorized error for non authenticated user'
do
delete
api
(
url
)
delete
api
(
url
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
it
'returns 404 not found error for a user without permissions to see the group'
do
it
'returns 404 not found error for a user without permissions to see the group'
do
...
@@ -180,13 +180,13 @@ describe API::EpicIssues do
...
@@ -180,13 +180,13 @@ describe API::EpicIssues do
delete
api
(
url
,
user
)
delete
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
'returns 403 forbidden error for a user without permissions to admin the epic'
do
it
'returns 403 forbidden error for a user without permissions to admin the epic'
do
delete
api
(
url
,
user
)
delete
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
context
'when epic_issue association does not include the epic in the url'
do
context
'when epic_issue association does not include the epic in the url'
do
...
@@ -202,7 +202,7 @@ describe API::EpicIssues do
...
@@ -202,7 +202,7 @@ describe API::EpicIssues do
it
'returns 404 not found error'
do
it
'returns 404 not found error'
do
delete
api
(
url
,
user
)
delete
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
@@ -215,7 +215,7 @@ describe API::EpicIssues do
...
@@ -215,7 +215,7 @@ describe API::EpicIssues do
it
'returns 200 status'
do
it
'returns 200 status'
do
delete
api
(
url
,
user
)
delete
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'matches the response schema'
do
it
'matches the response schema'
do
...
@@ -243,7 +243,7 @@ describe API::EpicIssues do
...
@@ -243,7 +243,7 @@ describe API::EpicIssues do
group
.
add_developer
(
user
)
group
.
add_developer
(
user
)
put
api
(
url
,
user
)
put
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -256,7 +256,7 @@ describe API::EpicIssues do
...
@@ -256,7 +256,7 @@ describe API::EpicIssues do
it
'returns 401 unauthorized error for non authenticated user'
do
it
'returns 401 unauthorized error for non authenticated user'
do
put
api
(
url
)
put
api
(
url
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
it
'returns 404 not found error for a user without permissions to see the group'
do
it
'returns 404 not found error for a user without permissions to see the group'
do
...
@@ -264,13 +264,13 @@ describe API::EpicIssues do
...
@@ -264,13 +264,13 @@ describe API::EpicIssues do
group
.
update
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
group
.
update
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
put
api
(
url
,
user
)
put
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
'returns 403 forbidden error for a user who can not move the issue'
do
it
'returns 403 forbidden error for a user who can not move the issue'
do
put
api
(
url
,
user
)
put
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
it
'returns 404 not found error for the link of another epic'
do
it
'returns 404 not found error for the link of another epic'
do
...
@@ -280,7 +280,7 @@ describe API::EpicIssues do
...
@@ -280,7 +280,7 @@ describe API::EpicIssues do
put
api
(
url
,
user
)
put
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -291,7 +291,7 @@ describe API::EpicIssues do
...
@@ -291,7 +291,7 @@ describe API::EpicIssues do
end
end
it
'returns 200 status'
do
it
'returns 200 status'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'updates the positions values'
do
it
'updates the positions values'
do
...
...
ee/spec/requests/api/epic_links_spec.rb
View file @
ad35e902
...
@@ -16,7 +16,7 @@ describe API::EpicLinks do
...
@@ -16,7 +16,7 @@ describe API::EpicLinks do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
context
'unauthenticated user'
do
context
'unauthenticated user'
do
...
@@ -25,7 +25,7 @@ describe API::EpicLinks do
...
@@ -25,7 +25,7 @@ describe API::EpicLinks do
it
'returns 401 unauthorized error'
do
it
'returns 401 unauthorized error'
do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
...
@@ -34,7 +34,7 @@ describe API::EpicLinks do
...
@@ -34,7 +34,7 @@ describe API::EpicLinks do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -59,7 +59,7 @@ describe API::EpicLinks do
...
@@ -59,7 +59,7 @@ describe API::EpicLinks do
epics
=
json_response
epics
=
json_response
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/epics'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/epics'
,
dir:
'ee'
)
expect
(
epics
.
map
{
|
epic
|
epic
[
"id"
]
}).
to
eq
([
child_epic2
.
id
,
child_epic1
.
id
])
expect
(
epics
.
map
{
|
epic
|
epic
[
"id"
]
}).
to
eq
([
child_epic2
.
id
,
child_epic1
.
id
])
end
end
...
@@ -85,7 +85,7 @@ describe API::EpicLinks do
...
@@ -85,7 +85,7 @@ describe API::EpicLinks do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -95,7 +95,7 @@ describe API::EpicLinks do
...
@@ -95,7 +95,7 @@ describe API::EpicLinks do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/epic'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/epic'
,
dir:
'ee'
)
expect
(
epic
.
reload
.
children
).
to
include
(
child_epic
)
expect
(
epic
.
reload
.
children
).
to
include
(
child_epic
)
end
end
...
@@ -110,7 +110,7 @@ describe API::EpicLinks do
...
@@ -110,7 +110,7 @@ describe API::EpicLinks do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
@@ -134,7 +134,7 @@ describe API::EpicLinks do
...
@@ -134,7 +134,7 @@ describe API::EpicLinks do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -146,7 +146,7 @@ describe API::EpicLinks do
...
@@ -146,7 +146,7 @@ describe API::EpicLinks do
it
'returns 201 status'
do
it
'returns 201 status'
do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/linked_epic'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/linked_epic'
,
dir:
'ee'
)
expect
(
epic
.
reload
.
children
).
to
include
(
Epic
.
last
)
expect
(
epic
.
reload
.
children
).
to
include
(
Epic
.
last
)
end
end
...
@@ -162,7 +162,7 @@ describe API::EpicLinks do
...
@@ -162,7 +162,7 @@ describe API::EpicLinks do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
end
end
...
@@ -193,7 +193,7 @@ describe API::EpicLinks do
...
@@ -193,7 +193,7 @@ describe API::EpicLinks do
it
'returns status 200'
do
it
'returns status 200'
do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/epics'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/epics'
,
dir:
'ee'
)
expect
(
json_response
.
map
{
|
epic
|
epic
[
'id'
]
}).
to
eq
([
sibling_1
.
id
,
child_epic
.
id
,
sibling_2
.
id
])
expect
(
json_response
.
map
{
|
epic
|
epic
[
'id'
]
}).
to
eq
([
sibling_1
.
id
,
child_epic
.
id
,
sibling_2
.
id
])
end
end
...
@@ -205,7 +205,7 @@ describe API::EpicLinks do
...
@@ -205,7 +205,7 @@ describe API::EpicLinks do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -230,7 +230,7 @@ describe API::EpicLinks do
...
@@ -230,7 +230,7 @@ describe API::EpicLinks do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -240,7 +240,7 @@ describe API::EpicLinks do
...
@@ -240,7 +240,7 @@ describe API::EpicLinks do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/epic'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/epic'
,
dir:
'ee'
)
expect
(
epic
.
reload
.
children
).
not_to
include
(
child_epic
)
expect
(
epic
.
reload
.
children
).
not_to
include
(
child_epic
)
end
end
...
...
ee/spec/requests/api/epics_spec.rb
View file @
ad35e902
...
@@ -17,7 +17,7 @@ describe API::Epics do
...
@@ -17,7 +17,7 @@ describe API::Epics do
get
api
(
url
,
user
),
params:
params
get
api
(
url
,
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
context
'when epics feature is enabled'
do
context
'when epics feature is enabled'
do
...
@@ -31,7 +31,7 @@ describe API::Epics do
...
@@ -31,7 +31,7 @@ describe API::Epics do
get
api
(
url
,
user
),
params:
params
get
api
(
url
,
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
@@ -77,7 +77,7 @@ describe API::Epics do
...
@@ -77,7 +77,7 @@ describe API::Epics do
end
end
it
'returns 200 status'
do
it
'returns 200 status'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'matches the response schema'
do
it
'matches the response schema'
do
...
@@ -100,7 +100,7 @@ describe API::Epics do
...
@@ -100,7 +100,7 @@ describe API::Epics do
create_list
(
:labeled_epic
,
2
,
group:
group
,
labels:
[
label_2
])
create_list
(
:labeled_epic
,
2
,
group:
group
,
labels:
[
label_2
])
expect
{
get
api
(
url
,
personal_access_token:
pat
),
params:
params
}.
not_to
exceed_all_query_limit
(
control
)
expect
{
get
api
(
url
,
personal_access_token:
pat
),
params:
params
}.
not_to
exceed_all_query_limit
(
control
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
context
'with_label_details'
do
context
'with_label_details'
do
...
@@ -141,7 +141,7 @@ describe API::Epics do
...
@@ -141,7 +141,7 @@ describe API::Epics do
get
api
(
url
),
params:
{
labels:
[
label
.
title
,
label_1
.
title
,
label_2
.
title
],
with_labels_details:
true
}
get
api
(
url
),
params:
{
labels:
[
label
.
title
,
label_1
.
title
,
label_2
.
title
],
with_labels_details:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect_paginated_array_response
([
epic
.
id
])
expect_paginated_array_response
([
epic
.
id
])
expect
(
json_response
.
first
[
'labels'
].
pluck
(
'name'
)).
to
match_array
([
label
.
title
,
label_1
.
title
,
label_2
.
title
])
expect
(
json_response
.
first
[
'labels'
].
pluck
(
'name'
)).
to
match_array
([
label
.
title
,
label_1
.
title
,
label_2
.
title
])
expect
(
json_response
.
last
[
'labels'
].
first
).
to
match_schema
(
'/public_api/v4/label_basic'
)
expect
(
json_response
.
last
[
'labels'
].
first
).
to
match_schema
(
'/public_api/v4/label_basic'
)
...
@@ -210,7 +210,7 @@ describe API::Epics do
...
@@ -210,7 +210,7 @@ describe API::Epics do
get
api
(
url
)
get
api
(
url
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
contain_exactly
(
expect
(
json_response
).
to
contain_exactly
(
a_hash_including
(
'upvotes'
=>
1
,
'downvotes'
=>
0
),
a_hash_including
(
'upvotes'
=>
1
,
'downvotes'
=>
0
),
...
@@ -481,7 +481,7 @@ describe API::Epics do
...
@@ -481,7 +481,7 @@ describe API::Epics do
it
'returns 200 status'
do
it
'returns 200 status'
do
get
api
(
url
)
get
api
(
url
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'matches the response schema'
do
it
'matches the response schema'
do
...
@@ -543,7 +543,7 @@ describe API::Epics do
...
@@ -543,7 +543,7 @@ describe API::Epics do
it
'returns 400'
do
it
'returns 400'
do
post
api
(
url
,
user
),
params:
{
description:
'epic description'
}
post
api
(
url
,
user
),
params:
{
description:
'epic description'
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
...
@@ -553,7 +553,7 @@ describe API::Epics do
...
@@ -553,7 +553,7 @@ describe API::Epics do
end
end
it
'returns 201 status'
do
it
'returns 201 status'
do
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
end
end
it
'matches the response schema'
do
it
'matches the response schema'
do
...
@@ -630,7 +630,7 @@ describe API::Epics do
...
@@ -630,7 +630,7 @@ describe API::Epics do
it
'returns 403 forbidden error'
do
it
'returns 403 forbidden error'
do
put
api
(
url
,
user
),
params:
params
put
api
(
url
,
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -640,7 +640,7 @@ describe API::Epics do
...
@@ -640,7 +640,7 @@ describe API::Epics do
put
api
(
url
,
user
)
put
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
...
@@ -655,7 +655,7 @@ describe API::Epics do
...
@@ -655,7 +655,7 @@ describe API::Epics do
end
end
it
'returns 200 status'
do
it
'returns 200 status'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'matches the response schema'
do
it
'matches the response schema'
do
...
@@ -760,7 +760,7 @@ describe API::Epics do
...
@@ -760,7 +760,7 @@ describe API::Epics do
delete
api
(
url
,
user
)
delete
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -772,7 +772,7 @@ describe API::Epics do
...
@@ -772,7 +772,7 @@ describe API::Epics do
it
'returns 204 status'
do
it
'returns 204 status'
do
delete
api
(
url
,
user
)
delete
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
end
it
'removes an epic'
do
it
'removes an epic'
do
...
...
spec/requests/api/access_requests_spec.rb
View file @
ad35e902
...
@@ -37,7 +37,7 @@ describe API::AccessRequests do
...
@@ -37,7 +37,7 @@ describe API::AccessRequests do
user
=
public_send
(
type
)
user
=
public_send
(
type
)
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests"
,
user
)
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -47,7 +47,7 @@ describe API::AccessRequests do
...
@@ -47,7 +47,7 @@ describe API::AccessRequests do
it
'returns access requesters'
do
it
'returns access requesters'
do
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests"
,
maintainer
)
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests"
,
maintainer
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
size
).
to
eq
(
1
)
...
@@ -70,7 +70,7 @@ describe API::AccessRequests do
...
@@ -70,7 +70,7 @@ describe API::AccessRequests do
user
=
public_send
(
type
)
user
=
public_send
(
type
)
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests"
,
user
)
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
.
not_to
change
{
source
.
requesters
.
count
}
end
.
not_to
change
{
source
.
requesters
.
count
}
end
end
end
end
...
@@ -82,7 +82,7 @@ describe API::AccessRequests do
...
@@ -82,7 +82,7 @@ describe API::AccessRequests do
expect
do
expect
do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests"
,
access_requester
)
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests"
,
access_requester
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
.
not_to
change
{
source
.
requesters
.
count
}
end
.
not_to
change
{
source
.
requesters
.
count
}
end
end
end
end
...
@@ -97,7 +97,7 @@ describe API::AccessRequests do
...
@@ -97,7 +97,7 @@ describe API::AccessRequests do
expect
do
expect
do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests"
,
stranger
)
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests"
,
stranger
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
.
not_to
change
{
source
.
requesters
.
count
}
end
.
not_to
change
{
source
.
requesters
.
count
}
end
end
end
end
...
@@ -106,7 +106,7 @@ describe API::AccessRequests do
...
@@ -106,7 +106,7 @@ describe API::AccessRequests do
expect
do
expect
do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests"
,
stranger
)
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests"
,
stranger
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
end
.
to
change
{
source
.
requesters
.
count
}.
by
(
1
)
end
.
to
change
{
source
.
requesters
.
count
}.
by
(
1
)
# User attributes
# User attributes
...
@@ -137,7 +137,7 @@ describe API::AccessRequests do
...
@@ -137,7 +137,7 @@ describe API::AccessRequests do
user
=
public_send
(
type
)
user
=
public_send
(
type
)
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests/
#{
access_requester
.
id
}
/approve"
,
user
)
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests/
#{
access_requester
.
id
}
/approve"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -149,7 +149,7 @@ describe API::AccessRequests do
...
@@ -149,7 +149,7 @@ describe API::AccessRequests do
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests/
#{
access_requester
.
id
}
/approve"
,
maintainer
),
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests/
#{
access_requester
.
id
}
/approve"
,
maintainer
),
params:
{
access_level:
Member
::
MAINTAINER
}
params:
{
access_level:
Member
::
MAINTAINER
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
end
.
to
change
{
source
.
members
.
count
}.
by
(
1
)
end
.
to
change
{
source
.
members
.
count
}.
by
(
1
)
# User attributes
# User attributes
expect
(
json_response
[
'id'
]).
to
eq
(
access_requester
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
access_requester
.
id
)
...
@@ -168,7 +168,7 @@ describe API::AccessRequests do
...
@@ -168,7 +168,7 @@ describe API::AccessRequests do
expect
do
expect
do
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests/
#{
stranger
.
id
}
/approve"
,
maintainer
)
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests/
#{
stranger
.
id
}
/approve"
,
maintainer
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
.
not_to
change
{
source
.
members
.
count
}
end
.
not_to
change
{
source
.
members
.
count
}
end
end
end
end
...
@@ -189,7 +189,7 @@ describe API::AccessRequests do
...
@@ -189,7 +189,7 @@ describe API::AccessRequests do
user
=
public_send
(
type
)
user
=
public_send
(
type
)
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests/
#{
access_requester
.
id
}
"
,
user
)
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests/
#{
access_requester
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -200,7 +200,7 @@ describe API::AccessRequests do
...
@@ -200,7 +200,7 @@ describe API::AccessRequests do
expect
do
expect
do
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests/
#{
access_requester
.
id
}
"
,
access_requester
)
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests/
#{
access_requester
.
id
}
"
,
access_requester
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
.
to
change
{
source
.
requesters
.
count
}.
by
(
-
1
)
end
.
to
change
{
source
.
requesters
.
count
}.
by
(
-
1
)
end
end
end
end
...
@@ -210,7 +210,7 @@ describe API::AccessRequests do
...
@@ -210,7 +210,7 @@ describe API::AccessRequests do
expect
do
expect
do
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests/
#{
access_requester
.
id
}
"
,
maintainer
)
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests/
#{
access_requester
.
id
}
"
,
maintainer
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
.
to
change
{
source
.
requesters
.
count
}.
by
(
-
1
)
end
.
to
change
{
source
.
requesters
.
count
}.
by
(
-
1
)
end
end
...
@@ -219,7 +219,7 @@ describe API::AccessRequests do
...
@@ -219,7 +219,7 @@ describe API::AccessRequests do
expect
do
expect
do
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests/
#{
developer
.
id
}
"
,
maintainer
)
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests/
#{
developer
.
id
}
"
,
maintainer
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
.
not_to
change
{
source
.
requesters
.
count
}
end
.
not_to
change
{
source
.
requesters
.
count
}
end
end
end
end
...
@@ -229,7 +229,7 @@ describe API::AccessRequests do
...
@@ -229,7 +229,7 @@ describe API::AccessRequests do
expect
do
expect
do
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests/
#{
stranger
.
id
}
"
,
maintainer
)
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests/
#{
stranger
.
id
}
"
,
maintainer
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
.
not_to
change
{
source
.
requesters
.
count
}
end
.
not_to
change
{
source
.
requesters
.
count
}
end
end
end
end
...
...
spec/requests/api/appearance_spec.rb
View file @
ad35e902
...
@@ -11,7 +11,7 @@ describe API::Appearance, 'Appearance' do
...
@@ -11,7 +11,7 @@ describe API::Appearance, 'Appearance' do
it
"returns 403"
do
it
"returns 403"
do
get
api
(
"/application/appearance"
,
user
)
get
api
(
"/application/appearance"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -19,7 +19,7 @@ describe API::Appearance, 'Appearance' do
...
@@ -19,7 +19,7 @@ describe API::Appearance, 'Appearance' do
it
"returns appearance"
do
it
"returns appearance"
do
get
api
(
"/application/appearance"
,
admin
)
get
api
(
"/application/appearance"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
be_an
Hash
expect
(
json_response
).
to
be_an
Hash
expect
(
json_response
[
'description'
]).
to
eq
(
''
)
expect
(
json_response
[
'description'
]).
to
eq
(
''
)
expect
(
json_response
[
'email_header_and_footer_enabled'
]).
to
be
(
false
)
expect
(
json_response
[
'email_header_and_footer_enabled'
]).
to
be
(
false
)
...
@@ -41,7 +41,7 @@ describe API::Appearance, 'Appearance' do
...
@@ -41,7 +41,7 @@ describe API::Appearance, 'Appearance' do
it
"returns 403"
do
it
"returns 403"
do
put
api
(
"/application/appearance"
,
user
),
params:
{
title:
"Test"
}
put
api
(
"/application/appearance"
,
user
),
params:
{
title:
"Test"
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -54,7 +54,7 @@ describe API::Appearance, 'Appearance' do
...
@@ -54,7 +54,7 @@ describe API::Appearance, 'Appearance' do
new_project_guidelines:
"Please read the FAQs for help."
new_project_guidelines:
"Please read the FAQs for help."
}
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
be_an
Hash
expect
(
json_response
).
to
be_an
Hash
expect
(
json_response
[
'description'
]).
to
eq
(
'gitlab-test.example.com'
)
expect
(
json_response
[
'description'
]).
to
eq
(
'gitlab-test.example.com'
)
expect
(
json_response
[
'email_header_and_footer_enabled'
]).
to
be
(
false
)
expect
(
json_response
[
'email_header_and_footer_enabled'
]).
to
be
(
false
)
...
@@ -82,7 +82,7 @@ describe API::Appearance, 'Appearance' do
...
@@ -82,7 +82,7 @@ describe API::Appearance, 'Appearance' do
put
api
(
"/application/appearance"
,
admin
),
params:
settings
put
api
(
"/application/appearance"
,
admin
),
params:
settings
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
settings
.
each
do
|
attribute
,
value
|
settings
.
each
do
|
attribute
,
value
|
expect
(
Appearance
.
current
.
public_send
(
attribute
)).
to
eq
(
value
)
expect
(
Appearance
.
current
.
public_send
(
attribute
)).
to
eq
(
value
)
end
end
...
@@ -92,14 +92,14 @@ describe API::Appearance, 'Appearance' do
...
@@ -92,14 +92,14 @@ describe API::Appearance, 'Appearance' do
it
"with message_font_color"
do
it
"with message_font_color"
do
put
api
(
"/application/appearance"
,
admin
),
params:
{
message_font_color:
"No Color"
}
put
api
(
"/application/appearance"
,
admin
),
params:
{
message_font_color:
"No Color"
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
][
'message_font_color'
]).
to
contain_exactly
(
'must be a valid color code'
)
expect
(
json_response
[
'message'
][
'message_font_color'
]).
to
contain_exactly
(
'must be a valid color code'
)
end
end
it
"with message_background_color"
do
it
"with message_background_color"
do
put
api
(
"/application/appearance"
,
admin
),
params:
{
message_background_color:
"#1"
}
put
api
(
"/application/appearance"
,
admin
),
params:
{
message_background_color:
"#1"
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
][
'message_background_color'
]).
to
contain_exactly
(
'must be a valid color code'
)
expect
(
json_response
[
'message'
][
'message_background_color'
]).
to
contain_exactly
(
'must be a valid color code'
)
end
end
end
end
...
@@ -115,7 +115,7 @@ describe API::Appearance, 'Appearance' do
...
@@ -115,7 +115,7 @@ describe API::Appearance, 'Appearance' do
favicon:
fixture_file_upload
(
"spec/fixtures/dk.png"
,
"image/png"
)
favicon:
fixture_file_upload
(
"spec/fixtures/dk.png"
,
"image/png"
)
}
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'logo'
]).
to
eq
(
"/uploads/-/system/appearance/logo/
#{
appearance
.
id
}
/dk.png"
)
expect
(
json_response
[
'logo'
]).
to
eq
(
"/uploads/-/system/appearance/logo/
#{
appearance
.
id
}
/dk.png"
)
expect
(
json_response
[
'header_logo'
]).
to
eq
(
"/uploads/-/system/appearance/header_logo/
#{
appearance
.
id
}
/dk.png"
)
expect
(
json_response
[
'header_logo'
]).
to
eq
(
"/uploads/-/system/appearance/header_logo/
#{
appearance
.
id
}
/dk.png"
)
expect
(
json_response
[
'favicon'
]).
to
eq
(
"/uploads/-/system/appearance/favicon/
#{
appearance
.
id
}
/dk.png"
)
expect
(
json_response
[
'favicon'
]).
to
eq
(
"/uploads/-/system/appearance/favicon/
#{
appearance
.
id
}
/dk.png"
)
...
@@ -125,14 +125,14 @@ describe API::Appearance, 'Appearance' do
...
@@ -125,14 +125,14 @@ describe API::Appearance, 'Appearance' do
it
"with string instead of file"
do
it
"with string instead of file"
do
put
api
(
"/application/appearance"
,
admin
),
params:
{
logo:
'not-a-file.png'
}
put
api
(
"/application/appearance"
,
admin
),
params:
{
logo:
'not-a-file.png'
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'error'
]).
to
eq
(
"logo is invalid"
)
expect
(
json_response
[
'error'
]).
to
eq
(
"logo is invalid"
)
end
end
it
"with .svg file instead of .png"
do
it
"with .svg file instead of .png"
do
put
api
(
"/application/appearance"
,
admin
),
params:
{
favicon:
fixture_file_upload
(
"spec/fixtures/logo_sample.svg"
,
"image/svg"
)
}
put
api
(
"/application/appearance"
,
admin
),
params:
{
favicon:
fixture_file_upload
(
"spec/fixtures/logo_sample.svg"
,
"image/svg"
)
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
][
'favicon'
]).
to
contain_exactly
(
"You are not allowed to upload
\"
svg
\"
files, allowed types: png, ico"
)
expect
(
json_response
[
'message'
][
'favicon'
]).
to
contain_exactly
(
"You are not allowed to upload
\"
svg
\"
files, allowed types: png, ico"
)
end
end
end
end
...
...
spec/requests/api/applications_spec.rb
View file @
ad35e902
...
@@ -16,7 +16,7 @@ describe API::Applications, :api do
...
@@ -16,7 +16,7 @@ describe API::Applications, :api do
application
=
Doorkeeper
::
Application
.
find_by
(
name:
'application_name'
,
redirect_uri:
'http://application.url'
)
application
=
Doorkeeper
::
Application
.
find_by
(
name:
'application_name'
,
redirect_uri:
'http://application.url'
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
[
'application_id'
]).
to
eq
application
.
uid
expect
(
json_response
[
'application_id'
]).
to
eq
application
.
uid
expect
(
json_response
[
'secret'
]).
to
eq
application
.
secret
expect
(
json_response
[
'secret'
]).
to
eq
application
.
secret
...
@@ -29,7 +29,7 @@ describe API::Applications, :api do
...
@@ -29,7 +29,7 @@ describe API::Applications, :api do
post
api
(
'/applications'
,
admin_user
),
params:
{
name:
'application_name'
,
redirect_uri:
'http://'
,
scopes:
''
}
post
api
(
'/applications'
,
admin_user
),
params:
{
name:
'application_name'
,
redirect_uri:
'http://'
,
scopes:
''
}
end
.
not_to
change
{
Doorkeeper
::
Application
.
count
}
end
.
not_to
change
{
Doorkeeper
::
Application
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
[
'message'
][
'redirect_uri'
][
0
]).
to
eq
(
'must be an absolute URI.'
)
expect
(
json_response
[
'message'
][
'redirect_uri'
][
0
]).
to
eq
(
'must be an absolute URI.'
)
end
end
...
@@ -39,7 +39,7 @@ describe API::Applications, :api do
...
@@ -39,7 +39,7 @@ describe API::Applications, :api do
post
api
(
'/applications'
,
admin_user
),
params:
{
name:
'application_name'
,
redirect_uri:
'javascript://alert()'
,
scopes:
''
}
post
api
(
'/applications'
,
admin_user
),
params:
{
name:
'application_name'
,
redirect_uri:
'javascript://alert()'
,
scopes:
''
}
end
.
not_to
change
{
Doorkeeper
::
Application
.
count
}
end
.
not_to
change
{
Doorkeeper
::
Application
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
[
'message'
][
'redirect_uri'
][
0
]).
to
eq
(
'is forbidden by the server.'
)
expect
(
json_response
[
'message'
][
'redirect_uri'
][
0
]).
to
eq
(
'is forbidden by the server.'
)
end
end
...
@@ -49,7 +49,7 @@ describe API::Applications, :api do
...
@@ -49,7 +49,7 @@ describe API::Applications, :api do
post
api
(
'/applications'
,
admin_user
),
params:
{
redirect_uri:
'http://application.url'
,
scopes:
''
}
post
api
(
'/applications'
,
admin_user
),
params:
{
redirect_uri:
'http://application.url'
,
scopes:
''
}
end
.
not_to
change
{
Doorkeeper
::
Application
.
count
}
end
.
not_to
change
{
Doorkeeper
::
Application
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
[
'error'
]).
to
eq
(
'name is missing'
)
expect
(
json_response
[
'error'
]).
to
eq
(
'name is missing'
)
end
end
...
@@ -59,7 +59,7 @@ describe API::Applications, :api do
...
@@ -59,7 +59,7 @@ describe API::Applications, :api do
post
api
(
'/applications'
,
admin_user
),
params:
{
name:
'application_name'
,
scopes:
''
}
post
api
(
'/applications'
,
admin_user
),
params:
{
name:
'application_name'
,
scopes:
''
}
end
.
not_to
change
{
Doorkeeper
::
Application
.
count
}
end
.
not_to
change
{
Doorkeeper
::
Application
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
[
'error'
]).
to
eq
(
'redirect_uri is missing'
)
expect
(
json_response
[
'error'
]).
to
eq
(
'redirect_uri is missing'
)
end
end
...
@@ -69,7 +69,7 @@ describe API::Applications, :api do
...
@@ -69,7 +69,7 @@ describe API::Applications, :api do
post
api
(
'/applications'
,
admin_user
),
params:
{
name:
'application_name'
,
redirect_uri:
'http://application.url'
}
post
api
(
'/applications'
,
admin_user
),
params:
{
name:
'application_name'
,
redirect_uri:
'http://application.url'
}
end
.
not_to
change
{
Doorkeeper
::
Application
.
count
}
end
.
not_to
change
{
Doorkeeper
::
Application
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
[
'error'
]).
to
eq
(
'scopes is missing'
)
expect
(
json_response
[
'error'
]).
to
eq
(
'scopes is missing'
)
end
end
...
@@ -79,7 +79,7 @@ describe API::Applications, :api do
...
@@ -79,7 +79,7 @@ describe API::Applications, :api do
post
api
(
'/applications'
,
admin_user
),
params:
{
name:
'application_name'
,
redirect_uri:
'http://application.url'
,
scopes:
''
,
confidential:
nil
}
post
api
(
'/applications'
,
admin_user
),
params:
{
name:
'application_name'
,
redirect_uri:
'http://application.url'
,
scopes:
''
,
confidential:
nil
}
end
.
not_to
change
{
Doorkeeper
::
Application
.
count
}
end
.
not_to
change
{
Doorkeeper
::
Application
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
[
'message'
][
'confidential'
].
first
).
to
eq
(
'is not included in the list'
)
expect
(
json_response
[
'message'
][
'confidential'
].
first
).
to
eq
(
'is not included in the list'
)
end
end
...
@@ -91,7 +91,7 @@ describe API::Applications, :api do
...
@@ -91,7 +91,7 @@ describe API::Applications, :api do
post
api
(
'/applications'
,
user
),
params:
{
name:
'application_name'
,
redirect_uri:
'http://application.url'
,
scopes:
''
}
post
api
(
'/applications'
,
user
),
params:
{
name:
'application_name'
,
redirect_uri:
'http://application.url'
,
scopes:
''
}
end
.
not_to
change
{
Doorkeeper
::
Application
.
count
}
end
.
not_to
change
{
Doorkeeper
::
Application
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -101,7 +101,7 @@ describe API::Applications, :api do
...
@@ -101,7 +101,7 @@ describe API::Applications, :api do
post
api
(
'/applications'
),
params:
{
name:
'application_name'
,
redirect_uri:
'http://application.url'
}
post
api
(
'/applications'
),
params:
{
name:
'application_name'
,
redirect_uri:
'http://application.url'
}
end
.
not_to
change
{
Doorkeeper
::
Application
.
count
}
end
.
not_to
change
{
Doorkeeper
::
Application
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
end
end
...
@@ -111,7 +111,7 @@ describe API::Applications, :api do
...
@@ -111,7 +111,7 @@ describe API::Applications, :api do
it
'can list application'
do
it
'can list application'
do
get
api
(
'/applications'
,
admin_user
)
get
api
(
'/applications'
,
admin_user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
be_a
(
Array
)
expect
(
json_response
).
to
be_a
(
Array
)
end
end
end
end
...
@@ -120,7 +120,7 @@ describe API::Applications, :api do
...
@@ -120,7 +120,7 @@ describe API::Applications, :api do
it
'cannot list application'
do
it
'cannot list application'
do
get
api
(
'/applications'
,
user
)
get
api
(
'/applications'
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -128,7 +128,7 @@ describe API::Applications, :api do
...
@@ -128,7 +128,7 @@ describe API::Applications, :api do
it
'cannot list application'
do
it
'cannot list application'
do
get
api
(
'/applications'
)
get
api
(
'/applications'
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
end
end
...
@@ -140,7 +140,7 @@ describe API::Applications, :api do
...
@@ -140,7 +140,7 @@ describe API::Applications, :api do
delete
api
(
"/applications/
#{
application
.
id
}
"
,
admin_user
)
delete
api
(
"/applications/
#{
application
.
id
}
"
,
admin_user
)
end
.
to
change
{
Doorkeeper
::
Application
.
count
}.
by
(
-
1
)
end
.
to
change
{
Doorkeeper
::
Application
.
count
}.
by
(
-
1
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
end
end
end
...
@@ -148,7 +148,7 @@ describe API::Applications, :api do
...
@@ -148,7 +148,7 @@ describe API::Applications, :api do
it
'cannot delete an application'
do
it
'cannot delete an application'
do
delete
api
(
"/applications/
#{
application
.
id
}
"
,
user
)
delete
api
(
"/applications/
#{
application
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -156,7 +156,7 @@ describe API::Applications, :api do
...
@@ -156,7 +156,7 @@ describe API::Applications, :api do
it
'cannot delete an application'
do
it
'cannot delete an application'
do
delete
api
(
"/applications/
#{
application
.
id
}
"
)
delete
api
(
"/applications/
#{
application
.
id
}
"
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
end
end
...
...
spec/requests/api/award_emoji_spec.rb
View file @
ad35e902
...
@@ -20,7 +20,7 @@ describe API::AwardEmoji do
...
@@ -20,7 +20,7 @@ describe API::AwardEmoji do
it
"returns an array of award_emoji"
do
it
"returns an array of award_emoji"
do
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
award_emoji
.
name
)
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
award_emoji
.
name
)
end
end
...
@@ -28,7 +28,7 @@ describe API::AwardEmoji do
...
@@ -28,7 +28,7 @@ describe API::AwardEmoji do
it
"returns a 404 error when issue id not found"
do
it
"returns a 404 error when issue id not found"
do
get
api
(
"/projects/
#{
project
.
id
}
/issues/12345/award_emoji"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/issues/12345/award_emoji"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -36,7 +36,7 @@ describe API::AwardEmoji do
...
@@ -36,7 +36,7 @@ describe API::AwardEmoji do
it
"returns an array of award_emoji"
do
it
"returns an array of award_emoji"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/award_emoji"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/award_emoji"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
downvote
.
name
)
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
downvote
.
name
)
...
@@ -50,7 +50,7 @@ describe API::AwardEmoji do
...
@@ -50,7 +50,7 @@ describe API::AwardEmoji do
it
'returns the awarded emoji'
do
it
'returns the awarded emoji'
do
get
api
(
"/projects/
#{
project
.
id
}
/snippets/
#{
snippet
.
id
}
/award_emoji"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/snippets/
#{
snippet
.
id
}
/award_emoji"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
award
.
name
)
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
award
.
name
)
end
end
...
@@ -62,7 +62,7 @@ describe API::AwardEmoji do
...
@@ -62,7 +62,7 @@ describe API::AwardEmoji do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/award_emoji"
,
user1
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/award_emoji"
,
user1
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
@@ -73,7 +73,7 @@ describe API::AwardEmoji do
...
@@ -73,7 +73,7 @@ describe API::AwardEmoji do
it
'returns an array of award emoji'
do
it
'returns an array of award emoji'
do
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/notes/
#{
note
.
id
}
/award_emoji"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/notes/
#{
note
.
id
}
/award_emoji"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
rocket
.
name
)
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
rocket
.
name
)
end
end
...
@@ -84,7 +84,7 @@ describe API::AwardEmoji do
...
@@ -84,7 +84,7 @@ describe API::AwardEmoji do
it
"returns the award emoji"
do
it
"returns the award emoji"
do
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji/
#{
award_emoji
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji/
#{
award_emoji
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'name'
]).
to
eq
(
award_emoji
.
name
)
expect
(
json_response
[
'name'
]).
to
eq
(
award_emoji
.
name
)
expect
(
json_response
[
'awardable_id'
]).
to
eq
(
issue
.
id
)
expect
(
json_response
[
'awardable_id'
]).
to
eq
(
issue
.
id
)
expect
(
json_response
[
'awardable_type'
]).
to
eq
(
"Issue"
)
expect
(
json_response
[
'awardable_type'
]).
to
eq
(
"Issue"
)
...
@@ -93,7 +93,7 @@ describe API::AwardEmoji do
...
@@ -93,7 +93,7 @@ describe API::AwardEmoji do
it
"returns a 404 error if the award is not found"
do
it
"returns a 404 error if the award is not found"
do
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji/12345"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji/12345"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -101,7 +101,7 @@ describe API::AwardEmoji do
...
@@ -101,7 +101,7 @@ describe API::AwardEmoji do
it
'returns the award emoji'
do
it
'returns the award emoji'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/award_emoji/
#{
downvote
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/award_emoji/
#{
downvote
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'name'
]).
to
eq
(
downvote
.
name
)
expect
(
json_response
[
'name'
]).
to
eq
(
downvote
.
name
)
expect
(
json_response
[
'awardable_id'
]).
to
eq
(
merge_request
.
id
)
expect
(
json_response
[
'awardable_id'
]).
to
eq
(
merge_request
.
id
)
expect
(
json_response
[
'awardable_type'
]).
to
eq
(
"MergeRequest"
)
expect
(
json_response
[
'awardable_type'
]).
to
eq
(
"MergeRequest"
)
...
@@ -115,7 +115,7 @@ describe API::AwardEmoji do
...
@@ -115,7 +115,7 @@ describe API::AwardEmoji do
it
'returns the awarded emoji'
do
it
'returns the awarded emoji'
do
get
api
(
"/projects/
#{
project
.
id
}
/snippets/
#{
snippet
.
id
}
/award_emoji/
#{
award
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/snippets/
#{
snippet
.
id
}
/award_emoji/
#{
award
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'name'
]).
to
eq
(
award
.
name
)
expect
(
json_response
[
'name'
]).
to
eq
(
award
.
name
)
expect
(
json_response
[
'awardable_id'
]).
to
eq
(
snippet
.
id
)
expect
(
json_response
[
'awardable_id'
]).
to
eq
(
snippet
.
id
)
expect
(
json_response
[
'awardable_type'
]).
to
eq
(
"Snippet"
)
expect
(
json_response
[
'awardable_type'
]).
to
eq
(
"Snippet"
)
...
@@ -128,7 +128,7 @@ describe API::AwardEmoji do
...
@@ -128,7 +128,7 @@ describe API::AwardEmoji do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/award_emoji/
#{
downvote
.
id
}
"
,
user1
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/award_emoji/
#{
downvote
.
id
}
"
,
user1
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
@@ -139,7 +139,7 @@ describe API::AwardEmoji do
...
@@ -139,7 +139,7 @@ describe API::AwardEmoji do
it
'returns an award emoji'
do
it
'returns an award emoji'
do
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/notes/
#{
note
.
id
}
/award_emoji/
#{
rocket
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/notes/
#{
note
.
id
}
/award_emoji/
#{
rocket
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
not_to
be_an
Array
expect
(
json_response
).
not_to
be_an
Array
expect
(
json_response
[
'name'
]).
to
eq
(
rocket
.
name
)
expect
(
json_response
[
'name'
]).
to
eq
(
rocket
.
name
)
end
end
...
@@ -152,7 +152,7 @@ describe API::AwardEmoji do
...
@@ -152,7 +152,7 @@ describe API::AwardEmoji do
it
"creates a new award emoji"
do
it
"creates a new award emoji"
do
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji"
,
user
),
params:
{
name:
'blowfish'
}
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji"
,
user
),
params:
{
name:
'blowfish'
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'name'
]).
to
eq
(
'blowfish'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'blowfish'
)
expect
(
json_response
[
'user'
][
'username'
]).
to
eq
(
user
.
username
)
expect
(
json_response
[
'user'
][
'username'
]).
to
eq
(
user
.
username
)
end
end
...
@@ -168,13 +168,13 @@ describe API::AwardEmoji do
...
@@ -168,13 +168,13 @@ describe API::AwardEmoji do
it
"returns a 400 bad request error if the name is not given"
do
it
"returns a 400 bad request error if the name is not given"
do
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
"returns a 401 unauthorized error if the user is not authenticated"
do
it
"returns a 401 unauthorized error if the user is not authenticated"
do
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji"
),
params:
{
name:
'thumbsup'
}
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji"
),
params:
{
name:
'thumbsup'
}
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
it
"normalizes +1 as thumbsup award"
do
it
"normalizes +1 as thumbsup award"
do
...
@@ -188,7 +188,7 @@ describe API::AwardEmoji do
...
@@ -188,7 +188,7 @@ describe API::AwardEmoji do
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji"
,
user
),
params:
{
name:
'thumbsup'
}
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji"
,
user
),
params:
{
name:
'thumbsup'
}
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji"
,
user
),
params:
{
name:
'thumbsup'
}
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji"
,
user
),
params:
{
name:
'thumbsup'
}
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
json_response
[
"message"
]).
to
match
(
"has already been taken"
)
expect
(
json_response
[
"message"
]).
to
match
(
"has already been taken"
)
end
end
end
end
...
@@ -200,7 +200,7 @@ describe API::AwardEmoji do
...
@@ -200,7 +200,7 @@ describe API::AwardEmoji do
post
api
(
"/projects/
#{
project
.
id
}
/snippets/
#{
snippet
.
id
}
/award_emoji"
,
user
),
params:
{
name:
'blowfish'
}
post
api
(
"/projects/
#{
project
.
id
}
/snippets/
#{
snippet
.
id
}
/award_emoji"
,
user
),
params:
{
name:
'blowfish'
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'name'
]).
to
eq
(
'blowfish'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'blowfish'
)
expect
(
json_response
[
'user'
][
'username'
]).
to
eq
(
user
.
username
)
expect
(
json_response
[
'user'
][
'username'
]).
to
eq
(
user
.
username
)
end
end
...
@@ -215,7 +215,7 @@ describe API::AwardEmoji do
...
@@ -215,7 +215,7 @@ describe API::AwardEmoji do
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/notes/
#{
note
.
id
}
/award_emoji"
,
user
),
params:
{
name:
'rocket'
}
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/notes/
#{
note
.
id
}
/award_emoji"
,
user
),
params:
{
name:
'rocket'
}
end
.
to
change
{
note
.
award_emoji
.
count
}.
from
(
0
).
to
(
1
)
end
.
to
change
{
note
.
award_emoji
.
count
}.
from
(
0
).
to
(
1
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'user'
][
'username'
]).
to
eq
(
user
.
username
)
expect
(
json_response
[
'user'
][
'username'
]).
to
eq
(
user
.
username
)
end
end
...
@@ -238,7 +238,7 @@ describe API::AwardEmoji do
...
@@ -238,7 +238,7 @@ describe API::AwardEmoji do
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/notes/
#{
note
.
id
}
/award_emoji"
,
user
),
params:
{
name:
'rocket'
}
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/notes/
#{
note
.
id
}
/award_emoji"
,
user
),
params:
{
name:
'rocket'
}
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/notes/
#{
note
.
id
}
/award_emoji"
,
user
),
params:
{
name:
'rocket'
}
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/notes/
#{
note
.
id
}
/award_emoji"
,
user
),
params:
{
name:
'rocket'
}
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
json_response
[
"message"
]).
to
match
(
"has already been taken"
)
expect
(
json_response
[
"message"
]).
to
match
(
"has already been taken"
)
end
end
end
end
...
@@ -250,14 +250,14 @@ describe API::AwardEmoji do
...
@@ -250,14 +250,14 @@ describe API::AwardEmoji do
expect
do
expect
do
delete
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji/
#{
award_emoji
.
id
}
"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji/
#{
award_emoji
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
.
to
change
{
issue
.
award_emoji
.
count
}.
from
(
1
).
to
(
0
)
end
.
to
change
{
issue
.
award_emoji
.
count
}.
from
(
1
).
to
(
0
)
end
end
it
'returns a 404 error when the award emoji can not be found'
do
it
'returns a 404 error when the award emoji can not be found'
do
delete
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji/12345"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/award_emoji/12345"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it_behaves_like
'412 response'
do
it_behaves_like
'412 response'
do
...
@@ -270,14 +270,14 @@ describe API::AwardEmoji do
...
@@ -270,14 +270,14 @@ describe API::AwardEmoji do
expect
do
expect
do
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/award_emoji/
#{
downvote
.
id
}
"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/award_emoji/
#{
downvote
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
.
to
change
{
merge_request
.
award_emoji
.
count
}.
from
(
1
).
to
(
0
)
end
.
to
change
{
merge_request
.
award_emoji
.
count
}.
from
(
1
).
to
(
0
)
end
end
it
'returns a 404 error when note id not found'
do
it
'returns a 404 error when note id not found'
do
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/notes/12345"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/notes/12345"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it_behaves_like
'412 response'
do
it_behaves_like
'412 response'
do
...
@@ -293,7 +293,7 @@ describe API::AwardEmoji do
...
@@ -293,7 +293,7 @@ describe API::AwardEmoji do
expect
do
expect
do
delete
api
(
"/projects/
#{
project
.
id
}
/snippets/
#{
snippet
.
id
}
/award_emoji/
#{
award
.
id
}
"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/snippets/
#{
snippet
.
id
}
/award_emoji/
#{
award
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
.
to
change
{
snippet
.
award_emoji
.
count
}.
from
(
1
).
to
(
0
)
end
.
to
change
{
snippet
.
award_emoji
.
count
}.
from
(
1
).
to
(
0
)
end
end
...
@@ -310,7 +310,7 @@ describe API::AwardEmoji do
...
@@ -310,7 +310,7 @@ describe API::AwardEmoji do
expect
do
expect
do
delete
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/notes/
#{
note
.
id
}
/award_emoji/
#{
rocket
.
id
}
"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/notes/
#{
note
.
id
}
/award_emoji/
#{
rocket
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
.
to
change
{
note
.
award_emoji
.
count
}.
from
(
1
).
to
(
0
)
end
.
to
change
{
note
.
award_emoji
.
count
}.
from
(
1
).
to
(
0
)
end
end
...
...
spec/requests/api/badges_spec.rb
View file @
ad35e902
...
@@ -35,7 +35,7 @@ describe API::Badges do
...
@@ -35,7 +35,7 @@ describe API::Badges do
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges"
,
user
)
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
badges_count
)
expect
(
json_response
.
size
).
to
eq
(
badges_count
)
...
@@ -80,7 +80,7 @@ describe API::Badges do
...
@@ -80,7 +80,7 @@ describe API::Badges do
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/
#{
badge
.
id
}
"
,
user
)
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/
#{
badge
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'name'
]).
to
eq
(
badge
.
name
)
expect
(
json_response
[
'name'
]).
to
eq
(
badge
.
name
)
expect
(
json_response
[
'id'
]).
to
eq
(
badge
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
badge
.
id
)
expect
(
json_response
[
'link_url'
]).
to
eq
(
badge
.
link_url
)
expect
(
json_response
[
'link_url'
]).
to
eq
(
badge
.
link_url
)
...
@@ -120,7 +120,7 @@ describe API::Badges do
...
@@ -120,7 +120,7 @@ describe API::Badges do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges"
,
user
),
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges"
,
user
),
params:
{
link_url:
example_url
,
image_url:
example_url2
}
params:
{
link_url:
example_url
,
image_url:
example_url2
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -132,7 +132,7 @@ describe API::Badges do
...
@@ -132,7 +132,7 @@ describe API::Badges do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges"
,
maintainer
),
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges"
,
maintainer
),
params:
{
name:
example_name
,
link_url:
example_url
,
image_url:
example_url2
}
params:
{
name:
example_name
,
link_url:
example_url
,
image_url:
example_url2
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
end
.
to
change
{
source
.
badges
.
count
}.
by
(
1
)
end
.
to
change
{
source
.
badges
.
count
}.
by
(
1
)
expect
(
json_response
[
'name'
]).
to
eq
(
example_name
)
expect
(
json_response
[
'name'
]).
to
eq
(
example_name
)
...
@@ -146,21 +146,21 @@ describe API::Badges do
...
@@ -146,21 +146,21 @@ describe API::Badges do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges"
,
maintainer
),
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges"
,
maintainer
),
params:
{
link_url:
example_url
}
params:
{
link_url:
example_url
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
'returns 400 when image_url is not given'
do
it
'returns 400 when image_url is not given'
do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges"
,
maintainer
),
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges"
,
maintainer
),
params:
{
image_url:
example_url2
}
params:
{
image_url:
example_url2
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
'returns 400 when link_url or image_url is not valid'
do
it
'returns 400 when link_url or image_url is not valid'
do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges"
,
maintainer
),
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges"
,
maintainer
),
params:
{
link_url:
'whatever'
,
image_url:
'whatever'
}
params:
{
link_url:
'whatever'
,
image_url:
'whatever'
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
end
end
...
@@ -192,7 +192,7 @@ describe API::Badges do
...
@@ -192,7 +192,7 @@ describe API::Badges do
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/
#{
badge
.
id
}
"
,
user
),
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/
#{
badge
.
id
}
"
,
user
),
params:
{
link_url:
example_url
}
params:
{
link_url:
example_url
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -203,7 +203,7 @@ describe API::Badges do
...
@@ -203,7 +203,7 @@ describe API::Badges do
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/
#{
badge
.
id
}
"
,
maintainer
),
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/
#{
badge
.
id
}
"
,
maintainer
),
params:
{
name:
example_name
,
link_url:
example_url
,
image_url:
example_url2
}
params:
{
name:
example_name
,
link_url:
example_url
,
image_url:
example_url2
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'name'
]).
to
eq
(
example_name
)
expect
(
json_response
[
'name'
]).
to
eq
(
example_name
)
expect
(
json_response
[
'link_url'
]).
to
eq
(
example_url
)
expect
(
json_response
[
'link_url'
]).
to
eq
(
example_url
)
expect
(
json_response
[
'image_url'
]).
to
eq
(
example_url2
)
expect
(
json_response
[
'image_url'
]).
to
eq
(
example_url2
)
...
@@ -215,7 +215,7 @@ describe API::Badges do
...
@@ -215,7 +215,7 @@ describe API::Badges do
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/
#{
badge
.
id
}
"
,
maintainer
),
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/
#{
badge
.
id
}
"
,
maintainer
),
params:
{
link_url:
'whatever'
,
image_url:
'whatever'
}
params:
{
link_url:
'whatever'
,
image_url:
'whatever'
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
end
end
...
@@ -240,7 +240,7 @@ describe API::Badges do
...
@@ -240,7 +240,7 @@ describe API::Badges do
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/
#{
badge
.
id
}
"
,
user
)
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/
#{
badge
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -251,7 +251,7 @@ describe API::Badges do
...
@@ -251,7 +251,7 @@ describe API::Badges do
expect
do
expect
do
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/
#{
badge
.
id
}
"
,
maintainer
)
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/
#{
badge
.
id
}
"
,
maintainer
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
.
to
change
{
source
.
badges
.
count
}.
by
(
-
1
)
end
.
to
change
{
source
.
badges
.
count
}.
by
(
-
1
)
end
end
...
@@ -263,7 +263,7 @@ describe API::Badges do
...
@@ -263,7 +263,7 @@ describe API::Badges do
it
'returns 404 if badge does not exist'
do
it
'returns 404 if badge does not exist'
do
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/123"
,
maintainer
)
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/123"
,
maintainer
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
@@ -290,7 +290,7 @@ describe API::Badges do
...
@@ -290,7 +290,7 @@ describe API::Badges do
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/render?link_url=
#{
example_url
}
&image_url=
#{
example_url2
}
"
,
user
)
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/render?link_url=
#{
example_url
}
&image_url=
#{
example_url2
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -300,7 +300,7 @@ describe API::Badges do
...
@@ -300,7 +300,7 @@ describe API::Badges do
it
'gets the rendered badge values'
do
it
'gets the rendered badge values'
do
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/render?link_url=
#{
example_url
}
&image_url=
#{
example_url2
}
"
,
maintainer
)
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/render?link_url=
#{
example_url
}
&image_url=
#{
example_url2
}
"
,
maintainer
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
.
keys
).
to
contain_exactly
(
'name'
,
'link_url'
,
'rendered_link_url'
,
'image_url'
,
'rendered_image_url'
)
expect
(
json_response
.
keys
).
to
contain_exactly
(
'name'
,
'link_url'
,
'rendered_link_url'
,
'image_url'
,
'rendered_image_url'
)
expect
(
json_response
[
'link_url'
]).
to
eq
(
example_url
)
expect
(
json_response
[
'link_url'
]).
to
eq
(
example_url
)
...
@@ -313,19 +313,19 @@ describe API::Badges do
...
@@ -313,19 +313,19 @@ describe API::Badges do
it
'returns 400 when link_url is not given'
do
it
'returns 400 when link_url is not given'
do
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/render?link_url=
#{
example_url
}
"
,
maintainer
)
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/render?link_url=
#{
example_url
}
"
,
maintainer
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
'returns 400 when image_url is not given'
do
it
'returns 400 when image_url is not given'
do
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/render?image_url=
#{
example_url
}
"
,
maintainer
)
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/render?image_url=
#{
example_url
}
"
,
maintainer
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
'returns 400 when link_url or image_url is not valid'
do
it
'returns 400 when link_url or image_url is not valid'
do
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/render?link_url=whatever&image_url=whatever"
,
maintainer
)
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/badges/render?link_url=whatever&image_url=whatever"
,
maintainer
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
end
end
...
@@ -335,7 +335,7 @@ describe API::Badges do
...
@@ -335,7 +335,7 @@ describe API::Badges do
it
'cannot delete badges owned by the project group'
do
it
'cannot delete badges owned by the project group'
do
delete
api
(
"/projects/
#{
project
.
id
}
/badges/
#{
project_group
.
badges
.
first
.
id
}
"
,
maintainer
)
delete
api
(
"/projects/
#{
project
.
id
}
/badges/
#{
project_group
.
badges
.
first
.
id
}
"
,
maintainer
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
...
spec/requests/api/boards_spec.rb
View file @
ad35e902
...
@@ -45,7 +45,7 @@ describe API::Boards do
...
@@ -45,7 +45,7 @@ describe API::Boards do
post
api
(
url
,
user
),
params:
{
label_id:
group_label
.
id
}
post
api
(
url
,
user
),
params:
{
label_id:
group_label
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'label'
][
'name'
]).
to
eq
(
group_label
.
title
)
expect
(
json_response
[
'label'
][
'name'
]).
to
eq
(
group_label
.
title
)
expect
(
json_response
[
'position'
]).
to
eq
(
3
)
expect
(
json_response
[
'position'
]).
to
eq
(
3
)
end
end
...
@@ -60,7 +60,7 @@ describe API::Boards do
...
@@ -60,7 +60,7 @@ describe API::Boards do
post
api
(
url
,
user
),
params:
{
label_id:
group_label
.
id
}
post
api
(
url
,
user
),
params:
{
label_id:
group_label
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'label'
][
'name'
]).
to
eq
(
group_label
.
title
)
expect
(
json_response
[
'label'
][
'name'
]).
to
eq
(
group_label
.
title
)
end
end
end
end
...
@@ -78,7 +78,7 @@ describe API::Boards do
...
@@ -78,7 +78,7 @@ describe API::Boards do
post
api
(
url
,
user
),
params:
{
label_id:
group_label
.
id
}
post
api
(
url
,
user
),
params:
{
label_id:
group_label
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'label'
][
'name'
]).
to
eq
(
group_label
.
title
)
expect
(
json_response
[
'label'
][
'name'
]).
to
eq
(
group_label
.
title
)
end
end
end
end
...
...
spec/requests/api/branches_spec.rb
View file @
ad35e902
...
@@ -31,7 +31,7 @@ describe API::Branches do
...
@@ -31,7 +31,7 @@ describe API::Branches do
it
'returns the repository branches'
do
it
'returns the repository branches'
do
get
api
(
route
,
current_user
),
params:
{
per_page:
100
}
get
api
(
route
,
current_user
),
params:
{
per_page:
100
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branches'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branches'
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
branch_names
=
json_response
.
map
{
|
x
|
x
[
'name'
]
}
branch_names
=
json_response
.
map
{
|
x
|
x
[
'name'
]
}
...
@@ -51,7 +51,7 @@ describe API::Branches do
...
@@ -51,7 +51,7 @@ describe API::Branches do
get
api
(
route
,
current_user
),
params:
{
per_page:
2
}
get
api
(
route
,
current_user
),
params:
{
per_page:
2
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
check_merge_status
(
json_response
)
check_merge_status
(
json_response
)
end
end
...
@@ -59,7 +59,7 @@ describe API::Branches do
...
@@ -59,7 +59,7 @@ describe API::Branches do
it
'merge status matches reality on paginated input'
do
it
'merge status matches reality on paginated input'
do
get
api
(
route
,
current_user
),
params:
{
per_page:
20
,
page:
2
}
get
api
(
route
,
current_user
),
params:
{
per_page:
20
,
page:
2
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
check_merge_status
(
json_response
)
check_merge_status
(
json_response
)
end
end
...
@@ -155,14 +155,14 @@ describe API::Branches do
...
@@ -155,14 +155,14 @@ describe API::Branches do
it
'returns 204 No Content'
do
it
'returns 204 No Content'
do
head
api
(
route
,
user
)
head
api
(
route
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
expect
(
response
.
body
).
to
be_empty
expect
(
response
.
body
).
to
be_empty
end
end
it
'returns 404 Not Found'
do
it
'returns 404 Not Found'
do
head
api
(
"/projects/
#{
project_id
}
/repository/branches/unknown"
,
user
)
head
api
(
"/projects/
#{
project_id
}
/repository/branches/unknown"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
response
.
body
).
to
be_empty
expect
(
response
.
body
).
to
be_empty
end
end
end
end
...
@@ -170,7 +170,7 @@ describe API::Branches do
...
@@ -170,7 +170,7 @@ describe API::Branches do
it
'returns the repository branch'
do
it
'returns the repository branch'
do
get
api
(
route
,
current_user
)
get
api
(
route
,
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branch'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branch'
)
expect
(
json_response
[
'name'
]).
to
eq
(
CGI
.
unescape
(
branch_name
))
expect
(
json_response
[
'name'
]).
to
eq
(
CGI
.
unescape
(
branch_name
))
end
end
...
@@ -298,7 +298,7 @@ describe API::Branches do
...
@@ -298,7 +298,7 @@ describe API::Branches do
it
'protects a single branch'
do
it
'protects a single branch'
do
put
api
(
route
,
current_user
)
put
api
(
route
,
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branch'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branch'
)
expect
(
json_response
[
'name'
]).
to
eq
(
CGI
.
unescape
(
branch_name
))
expect
(
json_response
[
'name'
]).
to
eq
(
CGI
.
unescape
(
branch_name
))
expect
(
json_response
[
'protected'
]).
to
eq
(
true
)
expect
(
json_response
[
'protected'
]).
to
eq
(
true
)
...
@@ -307,7 +307,7 @@ describe API::Branches do
...
@@ -307,7 +307,7 @@ describe API::Branches do
it
'protects a single branch and developers can push'
do
it
'protects a single branch and developers can push'
do
put
api
(
route
,
current_user
),
params:
{
developers_can_push:
true
}
put
api
(
route
,
current_user
),
params:
{
developers_can_push:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branch'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branch'
)
expect
(
json_response
[
'name'
]).
to
eq
(
CGI
.
unescape
(
branch_name
))
expect
(
json_response
[
'name'
]).
to
eq
(
CGI
.
unescape
(
branch_name
))
expect
(
json_response
[
'protected'
]).
to
eq
(
true
)
expect
(
json_response
[
'protected'
]).
to
eq
(
true
)
...
@@ -318,7 +318,7 @@ describe API::Branches do
...
@@ -318,7 +318,7 @@ describe API::Branches do
it
'protects a single branch and developers can merge'
do
it
'protects a single branch and developers can merge'
do
put
api
(
route
,
current_user
),
params:
{
developers_can_merge:
true
}
put
api
(
route
,
current_user
),
params:
{
developers_can_merge:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branch'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branch'
)
expect
(
json_response
[
'name'
]).
to
eq
(
CGI
.
unescape
(
branch_name
))
expect
(
json_response
[
'name'
]).
to
eq
(
CGI
.
unescape
(
branch_name
))
expect
(
json_response
[
'protected'
]).
to
eq
(
true
)
expect
(
json_response
[
'protected'
]).
to
eq
(
true
)
...
@@ -329,7 +329,7 @@ describe API::Branches do
...
@@ -329,7 +329,7 @@ describe API::Branches do
it
'protects a single branch and developers can push and merge'
do
it
'protects a single branch and developers can push and merge'
do
put
api
(
route
,
current_user
),
params:
{
developers_can_push:
true
,
developers_can_merge:
true
}
put
api
(
route
,
current_user
),
params:
{
developers_can_push:
true
,
developers_can_merge:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branch'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branch'
)
expect
(
json_response
[
'name'
]).
to
eq
(
CGI
.
unescape
(
branch_name
))
expect
(
json_response
[
'name'
]).
to
eq
(
CGI
.
unescape
(
branch_name
))
expect
(
json_response
[
'protected'
]).
to
eq
(
true
)
expect
(
json_response
[
'protected'
]).
to
eq
(
true
)
...
@@ -428,7 +428,7 @@ describe API::Branches do
...
@@ -428,7 +428,7 @@ describe API::Branches do
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
protected_branch
.
name
}
/protect"
,
user
),
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
protected_branch
.
name
}
/protect"
,
user
),
params:
{
developers_can_push:
false
,
developers_can_merge:
false
}
params:
{
developers_can_push:
false
,
developers_can_merge:
false
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branch'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branch'
)
expect
(
json_response
[
'name'
]).
to
eq
(
protected_branch
.
name
)
expect
(
json_response
[
'name'
]).
to
eq
(
protected_branch
.
name
)
expect
(
json_response
[
'protected'
]).
to
eq
(
true
)
expect
(
json_response
[
'protected'
]).
to
eq
(
true
)
...
@@ -446,7 +446,7 @@ describe API::Branches do
...
@@ -446,7 +446,7 @@ describe API::Branches do
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
protected_branch
.
name
}
/protect"
,
user
),
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
protected_branch
.
name
}
/protect"
,
user
),
params:
{
developers_can_push:
true
,
developers_can_merge:
true
}
params:
{
developers_can_push:
true
,
developers_can_merge:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branch'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branch'
)
expect
(
json_response
[
'name'
]).
to
eq
(
protected_branch
.
name
)
expect
(
json_response
[
'name'
]).
to
eq
(
protected_branch
.
name
)
expect
(
json_response
[
'protected'
]).
to
eq
(
true
)
expect
(
json_response
[
'protected'
]).
to
eq
(
true
)
...
@@ -465,7 +465,7 @@ describe API::Branches do
...
@@ -465,7 +465,7 @@ describe API::Branches do
it
'unprotects a single branch'
do
it
'unprotects a single branch'
do
put
api
(
route
,
current_user
)
put
api
(
route
,
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branch'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branch'
)
expect
(
json_response
[
'name'
]).
to
eq
(
CGI
.
unescape
(
branch_name
))
expect
(
json_response
[
'name'
]).
to
eq
(
CGI
.
unescape
(
branch_name
))
expect
(
json_response
[
'protected'
]).
to
eq
(
false
)
expect
(
json_response
[
'protected'
]).
to
eq
(
false
)
...
@@ -559,7 +559,7 @@ describe API::Branches do
...
@@ -559,7 +559,7 @@ describe API::Branches do
it
'creates a new branch'
do
it
'creates a new branch'
do
post
api
(
route
,
current_user
),
params:
{
branch:
'feature1'
,
ref:
branch_sha
}
post
api
(
route
,
current_user
),
params:
{
branch:
'feature1'
,
ref:
branch_sha
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branch'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/branch'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'feature1'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'feature1'
)
expect
(
json_response
[
'commit'
][
'id'
]).
to
eq
(
branch_sha
)
expect
(
json_response
[
'commit'
][
'id'
]).
to
eq
(
branch_sha
)
...
@@ -604,25 +604,25 @@ describe API::Branches do
...
@@ -604,25 +604,25 @@ describe API::Branches do
it
'returns 400 if branch name is invalid'
do
it
'returns 400 if branch name is invalid'
do
post
api
(
route
,
user
),
params:
{
branch:
'new design'
,
ref:
branch_sha
}
post
api
(
route
,
user
),
params:
{
branch:
'new design'
,
ref:
branch_sha
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Branch name is invalid'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Branch name is invalid'
)
end
end
it
'returns 400 if branch already exists'
,
:clean_gitlab_redis_cache
do
it
'returns 400 if branch already exists'
,
:clean_gitlab_redis_cache
do
post
api
(
route
,
user
),
params:
{
branch:
'new_design1'
,
ref:
branch_sha
}
post
api
(
route
,
user
),
params:
{
branch:
'new_design1'
,
ref:
branch_sha
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
post
api
(
route
,
user
),
params:
{
branch:
'new_design1'
,
ref:
branch_sha
}
post
api
(
route
,
user
),
params:
{
branch:
'new_design1'
,
ref:
branch_sha
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Branch already exists'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Branch already exists'
)
end
end
it
'returns 400 if ref name is invalid'
do
it
'returns 400 if ref name is invalid'
do
post
api
(
route
,
user
),
params:
{
branch:
'new_design3'
,
ref:
'foo'
}
post
api
(
route
,
user
),
params:
{
branch:
'new_design3'
,
ref:
'foo'
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Invalid reference name: new_design3'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Invalid reference name: new_design3'
)
end
end
end
end
...
@@ -637,19 +637,19 @@ describe API::Branches do
...
@@ -637,19 +637,19 @@ describe API::Branches do
it
'removes branch'
do
it
'removes branch'
do
delete
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
branch_name
}
"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
branch_name
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
end
it
'removes a branch with dots in the branch name'
do
it
'removes a branch with dots in the branch name'
do
delete
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
branch_with_dot
.
name
}
"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
branch_with_dot
.
name
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
end
it
'returns 404 if branch not exists'
do
it
'returns 404 if branch not exists'
do
delete
api
(
"/projects/
#{
project
.
id
}
/repository/branches/foobar"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/repository/branches/foobar"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
context
'when the branch refname is invalid'
do
context
'when the branch refname is invalid'
do
...
@@ -676,14 +676,14 @@ describe API::Branches do
...
@@ -676,14 +676,14 @@ describe API::Branches do
it
'returns 202 with json body'
do
it
'returns 202 with json body'
do
delete
api
(
"/projects/
#{
project
.
id
}
/repository/merged_branches"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/repository/merged_branches"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
202
)
expect
(
response
).
to
have_gitlab_http_status
(
:accepted
)
expect
(
json_response
[
'message'
]).
to
eql
(
'202 Accepted'
)
expect
(
json_response
[
'message'
]).
to
eql
(
'202 Accepted'
)
end
end
it
'returns a 403 error if guest'
do
it
'returns a 403 error if guest'
do
delete
api
(
"/projects/
#{
project
.
id
}
/repository/merged_branches"
,
guest
)
delete
api
(
"/projects/
#{
project
.
id
}
/repository/merged_branches"
,
guest
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
spec/requests/api/broadcast_messages_spec.rb
View file @
ad35e902
...
@@ -13,7 +13,7 @@ describe API::BroadcastMessages do
...
@@ -13,7 +13,7 @@ describe API::BroadcastMessages do
get
api
(
'/broadcast_messages'
)
get
api
(
'/broadcast_messages'
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_kind_of
(
Array
)
expect
(
json_response
).
to
be_kind_of
(
Array
)
expect
(
json_response
.
first
.
keys
)
expect
(
json_response
.
first
.
keys
)
...
@@ -25,7 +25,7 @@ describe API::BroadcastMessages do
...
@@ -25,7 +25,7 @@ describe API::BroadcastMessages do
it
'returns the specified message'
do
it
'returns the specified message'
do
get
api
(
"/broadcast_messages/
#{
message
.
id
}
"
)
get
api
(
"/broadcast_messages/
#{
message
.
id
}
"
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'id'
]).
to
eq
message
.
id
expect
(
json_response
[
'id'
]).
to
eq
message
.
id
expect
(
json_response
.
keys
)
expect
(
json_response
.
keys
)
.
to
match_array
(
%w(id message starts_at ends_at color font active target_path broadcast_type)
)
.
to
match_array
(
%w(id message starts_at ends_at color font active target_path broadcast_type)
)
...
@@ -36,13 +36,13 @@ describe API::BroadcastMessages do
...
@@ -36,13 +36,13 @@ describe API::BroadcastMessages do
it
'returns a 401 for anonymous users'
do
it
'returns a 401 for anonymous users'
do
post
api
(
'/broadcast_messages'
),
params:
attributes_for
(
:broadcast_message
)
post
api
(
'/broadcast_messages'
),
params:
attributes_for
(
:broadcast_message
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
it
'returns a 403 for users'
do
it
'returns a 403 for users'
do
post
api
(
'/broadcast_messages'
,
user
),
params:
attributes_for
(
:broadcast_message
)
post
api
(
'/broadcast_messages'
,
user
),
params:
attributes_for
(
:broadcast_message
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
context
'as an admin'
do
context
'as an admin'
do
...
@@ -52,7 +52,7 @@ describe API::BroadcastMessages do
...
@@ -52,7 +52,7 @@ describe API::BroadcastMessages do
post
api
(
'/broadcast_messages'
,
admin
),
params:
attrs
post
api
(
'/broadcast_messages'
,
admin
),
params:
attrs
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'error'
]).
to
eq
'message is missing'
expect
(
json_response
[
'error'
]).
to
eq
'message is missing'
end
end
...
@@ -61,7 +61,7 @@ describe API::BroadcastMessages do
...
@@ -61,7 +61,7 @@ describe API::BroadcastMessages do
travel_to
(
time
)
do
travel_to
(
time
)
do
post
api
(
'/broadcast_messages'
,
admin
),
params:
{
message:
'Test message'
}
post
api
(
'/broadcast_messages'
,
admin
),
params:
{
message:
'Test message'
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'starts_at'
]).
to
eq
'2016-07-02T10:11:12.000Z'
expect
(
json_response
[
'starts_at'
]).
to
eq
'2016-07-02T10:11:12.000Z'
expect
(
json_response
[
'ends_at'
]).
to
eq
'2016-07-02T11:11:12.000Z'
expect
(
json_response
[
'ends_at'
]).
to
eq
'2016-07-02T11:11:12.000Z'
end
end
...
@@ -72,7 +72,7 @@ describe API::BroadcastMessages do
...
@@ -72,7 +72,7 @@ describe API::BroadcastMessages do
post
api
(
'/broadcast_messages'
,
admin
),
params:
attrs
post
api
(
'/broadcast_messages'
,
admin
),
params:
attrs
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'color'
]).
to
eq
attrs
[
:color
]
expect
(
json_response
[
'color'
]).
to
eq
attrs
[
:color
]
expect
(
json_response
[
'font'
]).
to
eq
attrs
[
:font
]
expect
(
json_response
[
'font'
]).
to
eq
attrs
[
:font
]
end
end
...
@@ -82,7 +82,7 @@ describe API::BroadcastMessages do
...
@@ -82,7 +82,7 @@ describe API::BroadcastMessages do
post
api
(
'/broadcast_messages'
,
admin
),
params:
attrs
post
api
(
'/broadcast_messages'
,
admin
),
params:
attrs
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'target_path'
]).
to
eq
attrs
[
:target_path
]
expect
(
json_response
[
'target_path'
]).
to
eq
attrs
[
:target_path
]
end
end
...
@@ -91,7 +91,7 @@ describe API::BroadcastMessages do
...
@@ -91,7 +91,7 @@ describe API::BroadcastMessages do
post
api
(
'/broadcast_messages'
,
admin
),
params:
attrs
post
api
(
'/broadcast_messages'
,
admin
),
params:
attrs
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'broadcast_type'
]).
to
eq
attrs
[
:broadcast_type
]
expect
(
json_response
[
'broadcast_type'
]).
to
eq
attrs
[
:broadcast_type
]
end
end
...
@@ -100,7 +100,7 @@ describe API::BroadcastMessages do
...
@@ -100,7 +100,7 @@ describe API::BroadcastMessages do
post
api
(
'/broadcast_messages'
,
admin
),
params:
attrs
post
api
(
'/broadcast_messages'
,
admin
),
params:
attrs
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'broadcast_type'
]).
to
eq
'banner'
expect
(
json_response
[
'broadcast_type'
]).
to
eq
'banner'
end
end
...
@@ -109,7 +109,7 @@ describe API::BroadcastMessages do
...
@@ -109,7 +109,7 @@ describe API::BroadcastMessages do
post
api
(
'/broadcast_messages'
,
admin
),
params:
attrs
post
api
(
'/broadcast_messages'
,
admin
),
params:
attrs
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
end
end
...
@@ -119,14 +119,14 @@ describe API::BroadcastMessages do
...
@@ -119,14 +119,14 @@ describe API::BroadcastMessages do
put
api
(
"/broadcast_messages/
#{
message
.
id
}
"
),
put
api
(
"/broadcast_messages/
#{
message
.
id
}
"
),
params:
attributes_for
(
:broadcast_message
)
params:
attributes_for
(
:broadcast_message
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
it
'returns a 403 for users'
do
it
'returns a 403 for users'
do
put
api
(
"/broadcast_messages/
#{
message
.
id
}
"
,
user
),
put
api
(
"/broadcast_messages/
#{
message
.
id
}
"
,
user
),
params:
attributes_for
(
:broadcast_message
)
params:
attributes_for
(
:broadcast_message
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
context
'as an admin'
do
context
'as an admin'
do
...
@@ -135,7 +135,7 @@ describe API::BroadcastMessages do
...
@@ -135,7 +135,7 @@ describe API::BroadcastMessages do
put
api
(
"/broadcast_messages/
#{
message
.
id
}
"
,
admin
),
params:
attrs
put
api
(
"/broadcast_messages/
#{
message
.
id
}
"
,
admin
),
params:
attrs
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'color'
]).
to
eq
attrs
[
:color
]
expect
(
json_response
[
'color'
]).
to
eq
attrs
[
:color
]
expect
(
json_response
[
'font'
]).
to
eq
attrs
[
:font
]
expect
(
json_response
[
'font'
]).
to
eq
attrs
[
:font
]
end
end
...
@@ -147,7 +147,7 @@ describe API::BroadcastMessages do
...
@@ -147,7 +147,7 @@ describe API::BroadcastMessages do
put
api
(
"/broadcast_messages/
#{
message
.
id
}
"
,
admin
),
params:
attrs
put
api
(
"/broadcast_messages/
#{
message
.
id
}
"
,
admin
),
params:
attrs
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'starts_at'
]).
to
eq
'2016-07-02T10:11:12.000Z'
expect
(
json_response
[
'starts_at'
]).
to
eq
'2016-07-02T10:11:12.000Z'
expect
(
json_response
[
'ends_at'
]).
to
eq
'2016-07-02T13:11:12.000Z'
expect
(
json_response
[
'ends_at'
]).
to
eq
'2016-07-02T13:11:12.000Z'
end
end
...
@@ -158,7 +158,7 @@ describe API::BroadcastMessages do
...
@@ -158,7 +158,7 @@ describe API::BroadcastMessages do
put
api
(
"/broadcast_messages/
#{
message
.
id
}
"
,
admin
),
params:
attrs
put
api
(
"/broadcast_messages/
#{
message
.
id
}
"
,
admin
),
params:
attrs
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
{
message
.
reload
}.
to
change
{
message
.
message
}.
to
(
'new message'
)
expect
{
message
.
reload
}.
to
change
{
message
.
message
}.
to
(
'new message'
)
end
end
...
@@ -167,7 +167,7 @@ describe API::BroadcastMessages do
...
@@ -167,7 +167,7 @@ describe API::BroadcastMessages do
put
api
(
"/broadcast_messages/
#{
message
.
id
}
"
,
admin
),
params:
attrs
put
api
(
"/broadcast_messages/
#{
message
.
id
}
"
,
admin
),
params:
attrs
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'target_path'
]).
to
eq
attrs
[
:target_path
]
expect
(
json_response
[
'target_path'
]).
to
eq
attrs
[
:target_path
]
end
end
...
@@ -176,7 +176,7 @@ describe API::BroadcastMessages do
...
@@ -176,7 +176,7 @@ describe API::BroadcastMessages do
put
api
(
"/broadcast_messages/
#{
message
.
id
}
"
,
admin
),
params:
attrs
put
api
(
"/broadcast_messages/
#{
message
.
id
}
"
,
admin
),
params:
attrs
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'broadcast_type'
]).
to
eq
attrs
[
:broadcast_type
]
expect
(
json_response
[
'broadcast_type'
]).
to
eq
attrs
[
:broadcast_type
]
end
end
...
@@ -185,7 +185,7 @@ describe API::BroadcastMessages do
...
@@ -185,7 +185,7 @@ describe API::BroadcastMessages do
put
api
(
"/broadcast_messages/
#{
message
.
id
}
"
,
admin
),
params:
attrs
put
api
(
"/broadcast_messages/
#{
message
.
id
}
"
,
admin
),
params:
attrs
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
end
end
...
@@ -195,14 +195,14 @@ describe API::BroadcastMessages do
...
@@ -195,14 +195,14 @@ describe API::BroadcastMessages do
delete
api
(
"/broadcast_messages/
#{
message
.
id
}
"
),
delete
api
(
"/broadcast_messages/
#{
message
.
id
}
"
),
params:
attributes_for
(
:broadcast_message
)
params:
attributes_for
(
:broadcast_message
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
it
'returns a 403 for users'
do
it
'returns a 403 for users'
do
delete
api
(
"/broadcast_messages/
#{
message
.
id
}
"
,
user
),
delete
api
(
"/broadcast_messages/
#{
message
.
id
}
"
,
user
),
params:
attributes_for
(
:broadcast_message
)
params:
attributes_for
(
:broadcast_message
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
it_behaves_like
'412 response'
do
it_behaves_like
'412 response'
do
...
@@ -213,7 +213,7 @@ describe API::BroadcastMessages do
...
@@ -213,7 +213,7 @@ describe API::BroadcastMessages do
expect
do
expect
do
delete
api
(
"/broadcast_messages/
#{
message
.
id
}
"
,
admin
)
delete
api
(
"/broadcast_messages/
#{
message
.
id
}
"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
.
to
change
{
BroadcastMessage
.
count
}.
by
(
-
1
)
end
.
to
change
{
BroadcastMessage
.
count
}.
by
(
-
1
)
end
end
end
end
...
...
spec/requests/api/commit_statuses_spec.rb
View file @
ad35e902
...
@@ -37,7 +37,7 @@ describe API::CommitStatuses do
...
@@ -37,7 +37,7 @@ describe API::CommitStatuses do
end
end
it
'returns latest commit statuses'
do
it
'returns latest commit statuses'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
...
@@ -53,7 +53,7 @@ describe API::CommitStatuses do
...
@@ -53,7 +53,7 @@ describe API::CommitStatuses do
end
end
it
'returns all commit statuses'
do
it
'returns all commit statuses'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
statuses_id
).
to
contain_exactly
(
status1
.
id
,
status2
.
id
,
expect
(
statuses_id
).
to
contain_exactly
(
status1
.
id
,
status2
.
id
,
...
@@ -68,7 +68,7 @@ describe API::CommitStatuses do
...
@@ -68,7 +68,7 @@ describe API::CommitStatuses do
end
end
it
'returns latest commit statuses for specific ref'
do
it
'returns latest commit statuses for specific ref'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
statuses_id
).
to
contain_exactly
(
status3
.
id
,
status5
.
id
)
expect
(
statuses_id
).
to
contain_exactly
(
status3
.
id
,
status5
.
id
)
...
@@ -81,7 +81,7 @@ describe API::CommitStatuses do
...
@@ -81,7 +81,7 @@ describe API::CommitStatuses do
end
end
it
'return latest commit statuses for specific name'
do
it
'return latest commit statuses for specific name'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
statuses_id
).
to
contain_exactly
(
status4
.
id
,
status5
.
id
)
expect
(
statuses_id
).
to
contain_exactly
(
status4
.
id
,
status5
.
id
)
...
@@ -108,7 +108,7 @@ describe API::CommitStatuses do
...
@@ -108,7 +108,7 @@ describe API::CommitStatuses do
end
end
it
"does not return project commits"
do
it
"does not return project commits"
do
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -118,7 +118,7 @@ describe API::CommitStatuses do
...
@@ -118,7 +118,7 @@ describe API::CommitStatuses do
end
end
it
"does not return project commits"
do
it
"does not return project commits"
do
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
end
end
...
@@ -134,7 +134,7 @@ describe API::CommitStatuses do
...
@@ -134,7 +134,7 @@ describe API::CommitStatuses do
it
'creates commit status'
do
it
'creates commit status'
do
post
api
(
post_url
,
developer
),
params:
{
state:
status
}
post
api
(
post_url
,
developer
),
params:
{
state:
status
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'sha'
]).
to
eq
(
commit
.
id
)
expect
(
json_response
[
'sha'
]).
to
eq
(
commit
.
id
)
expect
(
json_response
[
'status'
]).
to
eq
(
status
)
expect
(
json_response
[
'status'
]).
to
eq
(
status
)
expect
(
json_response
[
'name'
]).
to
eq
(
'default'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'default'
)
...
@@ -162,7 +162,7 @@ describe API::CommitStatuses do
...
@@ -162,7 +162,7 @@ describe API::CommitStatuses do
job
=
pipeline
.
statuses
.
find_by_name
(
json_response
[
'name'
])
job
=
pipeline
.
statuses
.
find_by_name
(
json_response
[
'name'
])
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
job
.
status
).
to
eq
(
'pending'
)
expect
(
job
.
status
).
to
eq
(
'pending'
)
expect
(
job
.
stage_idx
).
to
eq
(
GenericCommitStatus
::
EXTERNAL_STAGE_IDX
)
expect
(
job
.
stage_idx
).
to
eq
(
GenericCommitStatus
::
EXTERNAL_STAGE_IDX
)
end
end
...
@@ -189,7 +189,7 @@ describe API::CommitStatuses do
...
@@ -189,7 +189,7 @@ describe API::CommitStatuses do
it
"to
#{
status
}
"
do
it
"to
#{
status
}
"
do
expect
{
post
api
(
post_url
,
developer
),
params:
{
state:
status
}
}.
not_to
change
{
CommitStatus
.
count
}
expect
{
post
api
(
post_url
,
developer
),
params:
{
state:
status
}
}.
not_to
change
{
CommitStatus
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'status'
]).
to
eq
(
status
)
expect
(
json_response
[
'status'
]).
to
eq
(
status
)
end
end
end
end
...
@@ -211,7 +211,7 @@ describe API::CommitStatuses do
...
@@ -211,7 +211,7 @@ describe API::CommitStatuses do
it
'creates commit status'
do
it
'creates commit status'
do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'sha'
]).
to
eq
(
commit
.
id
)
expect
(
json_response
[
'sha'
]).
to
eq
(
commit
.
id
)
expect
(
json_response
[
'status'
]).
to
eq
(
'success'
)
expect
(
json_response
[
'status'
]).
to
eq
(
'success'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'coverage'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'coverage'
)
...
@@ -227,7 +227,7 @@ describe API::CommitStatuses do
...
@@ -227,7 +227,7 @@ describe API::CommitStatuses do
it
'sets head pipeline'
do
it
'sets head pipeline'
do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
merge_request
.
reload
.
head_pipeline
).
not_to
be_nil
expect
(
merge_request
.
reload
.
head_pipeline
).
not_to
be_nil
end
end
end
end
...
@@ -254,7 +254,7 @@ describe API::CommitStatuses do
...
@@ -254,7 +254,7 @@ describe API::CommitStatuses do
end
end
it
'updates a commit status'
do
it
'updates a commit status'
do
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'sha'
]).
to
eq
(
commit
.
id
)
expect
(
json_response
[
'sha'
]).
to
eq
(
commit
.
id
)
expect
(
json_response
[
'status'
]).
to
eq
(
'success'
)
expect
(
json_response
[
'status'
]).
to
eq
(
'success'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'coverage'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'coverage'
)
...
@@ -300,7 +300,7 @@ describe API::CommitStatuses do
...
@@ -300,7 +300,7 @@ describe API::CommitStatuses do
end
end
it
'correctly posts a new commit status'
do
it
'correctly posts a new commit status'
do
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'sha'
]).
to
eq
(
commit
.
id
)
expect
(
json_response
[
'sha'
]).
to
eq
(
commit
.
id
)
expect
(
json_response
[
'status'
]).
to
eq
(
'success'
)
expect
(
json_response
[
'status'
]).
to
eq
(
'success'
)
end
end
...
@@ -318,7 +318,7 @@ describe API::CommitStatuses do
...
@@ -318,7 +318,7 @@ describe API::CommitStatuses do
end
end
it
'does not create commit status'
do
it
'does not create commit status'
do
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
...
@@ -328,7 +328,7 @@ describe API::CommitStatuses do
...
@@ -328,7 +328,7 @@ describe API::CommitStatuses do
end
end
it
'does not create commit status'
do
it
'does not create commit status'
do
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
...
@@ -342,7 +342,7 @@ describe API::CommitStatuses do
...
@@ -342,7 +342,7 @@ describe API::CommitStatuses do
let
(
:user
)
{
developer
}
let
(
:user
)
{
developer
}
it
'does not create commit status'
do
it
'does not create commit status'
do
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -350,7 +350,7 @@ describe API::CommitStatuses do
...
@@ -350,7 +350,7 @@ describe API::CommitStatuses do
let
(
:user
)
{
create_user
(
:maintainer
)
}
let
(
:user
)
{
create_user
(
:maintainer
)
}
it
'creates commit status'
do
it
'creates commit status'
do
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
end
end
end
end
end
end
...
@@ -363,7 +363,7 @@ describe API::CommitStatuses do
...
@@ -363,7 +363,7 @@ describe API::CommitStatuses do
end
end
it
'returns not found error'
do
it
'returns not found error'
do
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -376,7 +376,7 @@ describe API::CommitStatuses do
...
@@ -376,7 +376,7 @@ describe API::CommitStatuses do
end
end
it
'responds with bad request status and validation errors'
do
it
'responds with bad request status and validation errors'
do
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
][
'target_url'
])
expect
(
json_response
[
'message'
][
'target_url'
])
.
to
include
'is blocked: Only allowed schemes are http, https'
.
to
include
'is blocked: Only allowed schemes are http, https'
end
end
...
@@ -391,7 +391,7 @@ describe API::CommitStatuses do
...
@@ -391,7 +391,7 @@ describe API::CommitStatuses do
end
end
it
'responds with bad request status and validation errors'
do
it
'responds with bad request status and validation errors'
do
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
][
'target_url'
])
expect
(
json_response
[
'message'
][
'target_url'
])
.
to
include
'is blocked: Only allowed schemes are http, https'
.
to
include
'is blocked: Only allowed schemes are http, https'
end
end
...
@@ -407,7 +407,7 @@ describe API::CommitStatuses do
...
@@ -407,7 +407,7 @@ describe API::CommitStatuses do
end
end
it
'responds with bad request status and validation errors'
do
it
'responds with bad request status and validation errors'
do
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
][
'name'
])
expect
(
json_response
[
'message'
][
'name'
])
.
to
include
'has already been taken'
.
to
include
'has already been taken'
end
end
...
@@ -420,7 +420,7 @@ describe API::CommitStatuses do
...
@@ -420,7 +420,7 @@ describe API::CommitStatuses do
end
end
it
'does not create commit status'
do
it
'does not create commit status'
do
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -430,7 +430,7 @@ describe API::CommitStatuses do
...
@@ -430,7 +430,7 @@ describe API::CommitStatuses do
end
end
it
'does not create commit status'
do
it
'does not create commit status'
do
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -440,7 +440,7 @@ describe API::CommitStatuses do
...
@@ -440,7 +440,7 @@ describe API::CommitStatuses do
end
end
it
'does not create commit status'
do
it
'does not create commit status'
do
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
end
end
...
...
spec/requests/api/commits_spec.rb
View file @
ad35e902
...
@@ -28,7 +28,7 @@ describe API::Commits do
...
@@ -28,7 +28,7 @@ describe API::Commits do
get
api
(
route
,
current_user
)
get
api
(
route
,
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
schema
)
expect
(
response
).
to
match_response_schema
(
schema
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
commit
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
commit
.
id
)
expect
(
json_response
.
first
[
'committer_name'
]).
to
eq
(
commit
.
committer_name
)
expect
(
json_response
.
first
[
'committer_name'
]).
to
eq
(
commit
.
committer_name
)
...
@@ -123,7 +123,7 @@ describe API::Commits do
...
@@ -123,7 +123,7 @@ describe API::Commits do
it
"returns an invalid parameter error message"
do
it
"returns an invalid parameter error message"
do
get
api
(
"/projects/
#{
project_id
}
/repository/commits?since=invalid-date"
,
user
)
get
api
(
"/projects/
#{
project_id
}
/repository/commits?since=invalid-date"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'error'
]).
to
eq
(
'since is invalid'
)
expect
(
json_response
[
'error'
]).
to
eq
(
'since is invalid'
)
end
end
end
end
...
@@ -305,13 +305,13 @@ describe API::Commits do
...
@@ -305,13 +305,13 @@ describe API::Commits do
it
'returns a 403 unauthorized for user without permissions'
do
it
'returns a 403 unauthorized for user without permissions'
do
post
api
(
url
,
guest
)
post
api
(
url
,
guest
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
it
'returns a 400 bad request if no params are given'
do
it
'returns a 400 bad request if no params are given'
do
post
api
(
url
,
user
)
post
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
describe
'create'
do
describe
'create'
do
...
@@ -365,7 +365,7 @@ describe API::Commits do
...
@@ -365,7 +365,7 @@ describe API::Commits do
it
'a new file in project repo'
do
it
'a new file in project repo'
do
post
api
(
url
,
user
),
params:
valid_c_params
post
api
(
url
,
user
),
params:
valid_c_params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
expect
(
json_response
[
'committer_name'
]).
to
eq
(
user
.
name
)
expect
(
json_response
[
'committer_name'
]).
to
eq
(
user
.
name
)
expect
(
json_response
[
'committer_email'
]).
to
eq
(
user
.
email
)
expect
(
json_response
[
'committer_email'
]).
to
eq
(
user
.
email
)
...
@@ -374,7 +374,7 @@ describe API::Commits do
...
@@ -374,7 +374,7 @@ describe API::Commits do
it
'a new file with utf8 chars in project repo'
do
it
'a new file with utf8 chars in project repo'
do
post
api
(
url
,
user
),
params:
valid_utf8_c_params
post
api
(
url
,
user
),
params:
valid_utf8_c_params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
expect
(
json_response
[
'committer_name'
]).
to
eq
(
user
.
name
)
expect
(
json_response
[
'committer_name'
]).
to
eq
(
user
.
name
)
expect
(
json_response
[
'committer_email'
]).
to
eq
(
user
.
email
)
expect
(
json_response
[
'committer_email'
]).
to
eq
(
user
.
email
)
...
@@ -383,7 +383,7 @@ describe API::Commits do
...
@@ -383,7 +383,7 @@ describe API::Commits do
it
'returns a 400 bad request if file exists'
do
it
'returns a 400 bad request if file exists'
do
post
api
(
url
,
user
),
params:
invalid_c_params
post
api
(
url
,
user
),
params:
invalid_c_params
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
context
'with project path containing a dot in URL'
do
context
'with project path containing a dot in URL'
do
...
@@ -392,7 +392,7 @@ describe API::Commits do
...
@@ -392,7 +392,7 @@ describe API::Commits do
it
'a new file in project repo'
do
it
'a new file in project repo'
do
post
api
(
url
,
user
),
params:
valid_c_params
post
api
(
url
,
user
),
params:
valid_c_params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
end
end
end
end
...
@@ -414,7 +414,7 @@ describe API::Commits do
...
@@ -414,7 +414,7 @@ describe API::Commits do
it
'returns a 403'
do
it
'returns a 403'
do
post
api
(
url
,
guest
),
params:
valid_c_params
post
api
(
url
,
guest
),
params:
valid_c_params
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
context
'when start_project is provided'
do
context
'when start_project is provided'
do
...
@@ -456,7 +456,7 @@ describe API::Commits do
...
@@ -456,7 +456,7 @@ describe API::Commits do
it
'returns a 400'
do
it
'returns a 400'
do
post
api
(
url
,
guest
),
params:
valid_c_params
post
api
(
url
,
guest
),
params:
valid_c_params
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
]).
to
eq
(
"A branch called 'master' already exists. Switch to that branch in order to make changes"
)
expect
(
json_response
[
'message'
]).
to
eq
(
"A branch called 'master' already exists. Switch to that branch in order to make changes"
)
end
end
...
@@ -510,7 +510,7 @@ describe API::Commits do
...
@@ -510,7 +510,7 @@ describe API::Commits do
it
'returns a 403'
do
it
'returns a 403'
do
post
api
(
url
,
guest
),
params:
valid_c_params
post
api
(
url
,
guest
),
params:
valid_c_params
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -528,7 +528,7 @@ describe API::Commits do
...
@@ -528,7 +528,7 @@ describe API::Commits do
it
'returns a 403'
do
it
'returns a 403'
do
post
api
(
url
,
guest
),
params:
valid_c_params
post
api
(
url
,
guest
),
params:
valid_c_params
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -545,7 +545,7 @@ describe API::Commits do
...
@@ -545,7 +545,7 @@ describe API::Commits do
valid_c_params
[
:start_branch
]
=
'master'
valid_c_params
[
:start_branch
]
=
'master'
post
api
(
url
,
user
),
params:
valid_c_params
post
api
(
url
,
user
),
params:
valid_c_params
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'error'
]).
to
eq
(
'start_branch, start_sha are mutually exclusive'
)
expect
(
json_response
[
'error'
]).
to
eq
(
'start_branch, start_sha are mutually exclusive'
)
end
end
...
@@ -553,7 +553,7 @@ describe API::Commits do
...
@@ -553,7 +553,7 @@ describe API::Commits do
valid_c_params
[
:branch
]
=
'master'
valid_c_params
[
:branch
]
=
'master'
post
api
(
url
,
user
),
params:
valid_c_params
post
api
(
url
,
user
),
params:
valid_c_params
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
]).
to
eq
(
"A branch called 'master' already exists. Switch to that branch in order to make changes"
)
expect
(
json_response
[
'message'
]).
to
eq
(
"A branch called 'master' already exists. Switch to that branch in order to make changes"
)
end
end
...
@@ -561,7 +561,7 @@ describe API::Commits do
...
@@ -561,7 +561,7 @@ describe API::Commits do
valid_c_params
[
:start_sha
]
=
'1'
*
40
valid_c_params
[
:start_sha
]
=
'1'
*
40
post
api
(
url
,
user
),
params:
valid_c_params
post
api
(
url
,
user
),
params:
valid_c_params
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
]).
to
eq
(
"Cannot find start_sha '
#{
valid_c_params
[
:start_sha
]
}
'"
)
expect
(
json_response
[
'message'
]).
to
eq
(
"Cannot find start_sha '
#{
valid_c_params
[
:start_sha
]
}
'"
)
end
end
...
@@ -569,7 +569,7 @@ describe API::Commits do
...
@@ -569,7 +569,7 @@ describe API::Commits do
valid_c_params
[
:start_sha
]
=
start_sha
.
slice
(
0
,
7
)
valid_c_params
[
:start_sha
]
=
start_sha
.
slice
(
0
,
7
)
post
api
(
url
,
user
),
params:
valid_c_params
post
api
(
url
,
user
),
params:
valid_c_params
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
]).
to
eq
(
"Invalid start_sha '
#{
valid_c_params
[
:start_sha
]
}
'"
)
expect
(
json_response
[
'message'
]).
to
eq
(
"Invalid start_sha '
#{
valid_c_params
[
:start_sha
]
}
'"
)
end
end
...
@@ -630,14 +630,14 @@ describe API::Commits do
...
@@ -630,14 +630,14 @@ describe API::Commits do
it
'an existing file in project repo'
do
it
'an existing file in project repo'
do
post
api
(
url
,
user
),
params:
valid_d_params
post
api
(
url
,
user
),
params:
valid_d_params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
end
end
it
'returns a 400 bad request if file does not exist'
do
it
'returns a 400 bad request if file does not exist'
do
post
api
(
url
,
user
),
params:
invalid_d_params
post
api
(
url
,
user
),
params:
invalid_d_params
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
...
@@ -675,14 +675,14 @@ describe API::Commits do
...
@@ -675,14 +675,14 @@ describe API::Commits do
it
'an existing file in project repo'
do
it
'an existing file in project repo'
do
post
api
(
url
,
user
),
params:
valid_m_params
post
api
(
url
,
user
),
params:
valid_m_params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
end
end
it
'returns a 400 bad request if file does not exist'
do
it
'returns a 400 bad request if file does not exist'
do
post
api
(
url
,
user
),
params:
invalid_m_params
post
api
(
url
,
user
),
params:
invalid_m_params
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
...
@@ -718,14 +718,14 @@ describe API::Commits do
...
@@ -718,14 +718,14 @@ describe API::Commits do
it
'an existing file in project repo'
do
it
'an existing file in project repo'
do
post
api
(
url
,
user
),
params:
valid_u_params
post
api
(
url
,
user
),
params:
valid_u_params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
end
end
it
'returns a 400 bad request if file does not exist'
do
it
'returns a 400 bad request if file does not exist'
do
post
api
(
url
,
user
),
params:
invalid_u_params
post
api
(
url
,
user
),
params:
invalid_u_params
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
...
@@ -750,7 +750,7 @@ describe API::Commits do
...
@@ -750,7 +750,7 @@ describe API::Commits do
it
'responds with success'
do
it
'responds with success'
do
post
api
(
url
,
user
),
params:
params
post
api
(
url
,
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
end
end
...
@@ -760,7 +760,7 @@ describe API::Commits do
...
@@ -760,7 +760,7 @@ describe API::Commits do
it
'responds with success'
do
it
'responds with success'
do
post
api
(
url
,
user
),
params:
params
post
api
(
url
,
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
end
end
end
end
...
@@ -771,7 +771,7 @@ describe API::Commits do
...
@@ -771,7 +771,7 @@ describe API::Commits do
it
"responds with 400"
do
it
"responds with 400"
do
post
api
(
url
,
user
),
params:
params
post
api
(
url
,
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
]).
to
eq
(
"A file with this name doesn't exist"
)
expect
(
json_response
[
'message'
]).
to
eq
(
"A file with this name doesn't exist"
)
end
end
end
end
...
@@ -849,28 +849,28 @@ describe API::Commits do
...
@@ -849,28 +849,28 @@ describe API::Commits do
it
'are committed as one in project repo'
do
it
'are committed as one in project repo'
do
post
api
(
url
,
user
),
params:
valid_mo_params
post
api
(
url
,
user
),
params:
valid_mo_params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
end
end
it
'includes the commit stats'
do
it
'includes the commit stats'
do
post
api
(
url
,
user
),
params:
valid_mo_params
post
api
(
url
,
user
),
params:
valid_mo_params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
to
include
'stats'
expect
(
json_response
).
to
include
'stats'
end
end
it
"doesn't include the commit stats when stats is false"
do
it
"doesn't include the commit stats when stats is false"
do
post
api
(
url
,
user
),
params:
valid_mo_params
.
merge
(
stats:
false
)
post
api
(
url
,
user
),
params:
valid_mo_params
.
merge
(
stats:
false
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
not_to
include
'stats'
expect
(
json_response
).
not_to
include
'stats'
end
end
it
'return a 400 bad request if there are any issues'
do
it
'return a 400 bad request if there are any issues'
do
post
api
(
url
,
user
),
params:
invalid_mo_params
post
api
(
url
,
user
),
params:
invalid_mo_params
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
...
@@ -937,7 +937,7 @@ describe API::Commits do
...
@@ -937,7 +937,7 @@ describe API::Commits do
refs
=
project
.
repository
.
branch_names_contains
(
commit_id
).
map
{
|
name
|
[
'branch'
,
name
]}
refs
=
project
.
repository
.
branch_names_contains
(
commit_id
).
map
{
|
name
|
[
'branch'
,
name
]}
refs
.
concat
(
project
.
repository
.
tag_names_contains
(
commit_id
).
map
{
|
name
|
[
'tag'
,
name
]})
refs
.
concat
(
project
.
repository
.
tag_names_contains
(
commit_id
).
map
{
|
name
|
[
'tag'
,
name
]})
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
map
{
|
r
|
[
r
[
'type'
],
r
[
'name'
]]
}.
compact
).
to
eq
(
refs
)
expect
(
json_response
.
map
{
|
r
|
[
r
[
'type'
],
r
[
'name'
]]
}.
compact
).
to
eq
(
refs
)
...
@@ -949,7 +949,7 @@ describe API::Commits do
...
@@ -949,7 +949,7 @@ describe API::Commits do
refs
=
project
.
repository
.
branch_names_contains
(
commit_id
).
map
{
|
name
|
[
'branch'
,
name
]}
refs
=
project
.
repository
.
branch_names_contains
(
commit_id
).
map
{
|
name
|
[
'branch'
,
name
]}
refs
.
concat
(
project
.
repository
.
tag_names_contains
(
commit_id
).
map
{
|
name
|
[
'tag'
,
name
]})
refs
.
concat
(
project
.
repository
.
tag_names_contains
(
commit_id
).
map
{
|
name
|
[
'tag'
,
name
]})
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
.
map
{
|
r
|
[
r
[
'type'
],
r
[
'name'
]]
}.
compact
).
to
eq
(
refs
)
expect
(
json_response
.
map
{
|
r
|
[
r
[
'type'
],
r
[
'name'
]]
}.
compact
).
to
eq
(
refs
)
end
end
...
@@ -958,7 +958,7 @@ describe API::Commits do
...
@@ -958,7 +958,7 @@ describe API::Commits do
refs
=
project
.
repository
.
branch_names_contains
(
commit_id
).
map
{
|
name
|
[
'branch'
,
name
]}
refs
=
project
.
repository
.
branch_names_contains
(
commit_id
).
map
{
|
name
|
[
'branch'
,
name
]}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
.
map
{
|
r
|
[
r
[
'type'
],
r
[
'name'
]]
}.
compact
).
to
eq
(
refs
)
expect
(
json_response
.
map
{
|
r
|
[
r
[
'type'
],
r
[
'name'
]]
}.
compact
).
to
eq
(
refs
)
end
end
...
@@ -967,7 +967,7 @@ describe API::Commits do
...
@@ -967,7 +967,7 @@ describe API::Commits do
refs
=
project
.
repository
.
tag_names_contains
(
commit_id
).
map
{
|
name
|
[
'tag'
,
name
]}
refs
=
project
.
repository
.
tag_names_contains
(
commit_id
).
map
{
|
name
|
[
'tag'
,
name
]}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
.
map
{
|
r
|
[
r
[
'type'
],
r
[
'name'
]]
}.
compact
).
to
eq
(
refs
)
expect
(
json_response
.
map
{
|
r
|
[
r
[
'type'
],
r
[
'name'
]]
}.
compact
).
to
eq
(
refs
)
end
end
end
end
...
@@ -982,7 +982,7 @@ describe API::Commits do
...
@@ -982,7 +982,7 @@ describe API::Commits do
it
'returns the ref last commit'
do
it
'returns the ref last commit'
do
get
api
(
route
,
current_user
)
get
api
(
route
,
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit/detail'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit/detail'
)
expect
(
json_response
[
'id'
]).
to
eq
(
commit
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
commit
.
id
)
expect
(
json_response
[
'short_id'
]).
to
eq
(
commit
.
short_id
)
expect
(
json_response
[
'short_id'
]).
to
eq
(
commit
.
short_id
)
...
@@ -1030,7 +1030,7 @@ describe API::Commits do
...
@@ -1030,7 +1030,7 @@ describe API::Commits do
it
'includes status as "created" and a last_pipeline object'
do
it
'includes status as "created" and a last_pipeline object'
do
get
api
(
route
,
current_user
)
get
api
(
route
,
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit/detail'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit/detail'
)
expect
(
json_response
[
'status'
]).
to
eq
(
'created'
)
expect
(
json_response
[
'status'
]).
to
eq
(
'created'
)
expect
(
json_response
[
'last_pipeline'
][
'id'
]).
to
eq
(
pipeline
.
id
)
expect
(
json_response
[
'last_pipeline'
][
'id'
]).
to
eq
(
pipeline
.
id
)
...
@@ -1047,7 +1047,7 @@ describe API::Commits do
...
@@ -1047,7 +1047,7 @@ describe API::Commits do
it
'includes a "success" status'
do
it
'includes a "success" status'
do
get
api
(
route
,
current_user
)
get
api
(
route
,
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit/detail'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit/detail'
)
expect
(
json_response
[
'status'
]).
to
eq
(
'success'
)
expect
(
json_response
[
'status'
]).
to
eq
(
'success'
)
end
end
...
@@ -1065,7 +1065,7 @@ describe API::Commits do
...
@@ -1065,7 +1065,7 @@ describe API::Commits do
get
api
(
route
,
current_user
)
get
api
(
route
,
current_user
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit/detail'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit/detail'
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'last_pipeline'
]).
to
be_nil
expect
(
json_response
[
'last_pipeline'
]).
to
be_nil
end
end
end
end
...
@@ -1076,21 +1076,21 @@ describe API::Commits do
...
@@ -1076,21 +1076,21 @@ describe API::Commits do
it
'is not present return stats by default'
do
it
'is not present return stats by default'
do
get
api
(
route
,
user
)
get
api
(
route
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
include
'stats'
expect
(
json_response
).
to
include
'stats'
end
end
it
"is false it does not include stats"
do
it
"is false it does not include stats"
do
get
api
(
route
,
user
),
params:
{
stats:
false
}
get
api
(
route
,
user
),
params:
{
stats:
false
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
not_to
include
'stats'
expect
(
json_response
).
not_to
include
'stats'
end
end
it
"is true it includes stats"
do
it
"is true it includes stats"
do
get
api
(
route
,
user
),
params:
{
stats:
true
}
get
api
(
route
,
user
),
params:
{
stats:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
include
'stats'
expect
(
json_response
).
to
include
'stats'
end
end
end
end
...
@@ -1227,7 +1227,7 @@ describe API::Commits do
...
@@ -1227,7 +1227,7 @@ describe API::Commits do
it
'returns the diff of the selected commit'
do
it
'returns the diff of the selected commit'
do
get
api
(
route
,
current_user
)
get
api
(
route
,
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
.
size
).
to
be
>=
1
expect
(
json_response
.
size
).
to
be
>=
1
expect
(
json_response
.
first
.
keys
).
to
include
'diff'
expect
(
json_response
.
first
.
keys
).
to
include
'diff'
...
@@ -1241,7 +1241,7 @@ describe API::Commits do
...
@@ -1241,7 +1241,7 @@ describe API::Commits do
it
'respects the limit'
do
it
'respects the limit'
do
get
api
(
route
,
current_user
)
get
api
(
route
,
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
.
size
).
to
be
<=
1
expect
(
json_response
.
size
).
to
be
<=
1
end
end
...
@@ -1338,7 +1338,7 @@ describe API::Commits do
...
@@ -1338,7 +1338,7 @@ describe API::Commits do
it
'returns the diff of the selected commit'
do
it
'returns the diff of the selected commit'
do
get
api
(
route
,
current_user
)
get
api
(
route
,
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit_notes'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit_notes'
)
expect
(
json_response
.
size
).
to
eq
(
2
)
expect
(
json_response
.
size
).
to
eq
(
2
)
expect
(
json_response
.
first
[
'note'
]).
to
eq
(
'a comment on a commit'
)
expect
(
json_response
.
first
[
'note'
]).
to
eq
(
'a comment on a commit'
)
...
@@ -1428,7 +1428,7 @@ describe API::Commits do
...
@@ -1428,7 +1428,7 @@ describe API::Commits do
it
'returns the comments for the target project'
do
it
'returns the comments for the target project'
do
get
api
(
route
,
guest
)
get
api
(
route
,
guest
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit_notes'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit_notes'
)
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'note'
]).
to
eq
(
'a comment on a commit for fork'
)
expect
(
json_response
.
first
[
'note'
]).
to
eq
(
'a comment on a commit for fork'
)
...
@@ -1448,7 +1448,7 @@ describe API::Commits do
...
@@ -1448,7 +1448,7 @@ describe API::Commits do
it
'cherry-picks the ref commit'
do
it
'cherry-picks the ref commit'
do
post
api
(
route
,
current_user
),
params:
{
branch:
branch
}
post
api
(
route
,
current_user
),
params:
{
branch:
branch
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit/basic'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit/basic'
)
expect
(
json_response
[
'title'
]).
to
eq
(
commit
.
title
)
expect
(
json_response
[
'title'
]).
to
eq
(
commit
.
title
)
expect
(
json_response
[
'message'
]).
to
eq
(
commit
.
cherry_pick_message
(
user
))
expect
(
json_response
[
'message'
]).
to
eq
(
commit
.
cherry_pick_message
(
user
))
...
@@ -1608,7 +1608,7 @@ describe API::Commits do
...
@@ -1608,7 +1608,7 @@ describe API::Commits do
it
'reverts the ref commit'
do
it
'reverts the ref commit'
do
post
api
(
route
,
current_user
),
params:
{
branch:
branch
}
post
api
(
route
,
current_user
),
params:
{
branch:
branch
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit/basic'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit/basic'
)
expect
(
json_response
[
'message'
]).
to
eq
(
commit
.
revert_message
(
user
))
expect
(
json_response
[
'message'
]).
to
eq
(
commit
.
revert_message
(
user
))
...
@@ -1694,7 +1694,7 @@ describe API::Commits do
...
@@ -1694,7 +1694,7 @@ describe API::Commits do
# Second one is redundant and should be empty
# Second one is redundant and should be empty
post
api
(
route
,
current_user
),
params:
{
branch:
'markdown'
}
post
api
(
route
,
current_user
),
params:
{
branch:
'markdown'
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'error_code'
]).
to
eq
'empty'
expect
(
json_response
[
'error_code'
]).
to
eq
'empty'
end
end
end
end
...
@@ -1733,7 +1733,7 @@ describe API::Commits do
...
@@ -1733,7 +1733,7 @@ describe API::Commits do
it
'creates the comment'
do
it
'creates the comment'
do
post
api
(
route
,
current_user
),
params:
{
note:
note
}
post
api
(
route
,
current_user
),
params:
{
note:
note
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit_note'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit_note'
)
expect
(
json_response
[
'note'
]).
to
eq
(
'My comment'
)
expect
(
json_response
[
'note'
]).
to
eq
(
'My comment'
)
expect
(
json_response
[
'path'
]).
to
be_nil
expect
(
json_response
[
'path'
]).
to
be_nil
...
@@ -1774,7 +1774,7 @@ describe API::Commits do
...
@@ -1774,7 +1774,7 @@ describe API::Commits do
it
'returns the inline comment'
do
it
'returns the inline comment'
do
post
api
(
route
,
current_user
),
params:
{
note:
'My comment'
,
path:
project
.
repository
.
commit
.
raw_diffs
.
first
.
new_path
,
line:
1
,
line_type:
'new'
}
post
api
(
route
,
current_user
),
params:
{
note:
'My comment'
,
path:
project
.
repository
.
commit
.
raw_diffs
.
first
.
new_path
,
line:
1
,
line_type:
'new'
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit_note'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit_note'
)
expect
(
json_response
[
'note'
]).
to
eq
(
'My comment'
)
expect
(
json_response
[
'note'
]).
to
eq
(
'My comment'
)
expect
(
json_response
[
'path'
]).
to
eq
(
project
.
repository
.
commit
.
raw_diffs
.
first
.
new_path
)
expect
(
json_response
[
'path'
]).
to
eq
(
project
.
repository
.
commit
.
raw_diffs
.
first
.
new_path
)
...
@@ -1794,7 +1794,7 @@ describe API::Commits do
...
@@ -1794,7 +1794,7 @@ describe API::Commits do
it
'returns 400 if note is missing'
do
it
'returns 400 if note is missing'
do
post
api
(
route
,
current_user
)
post
api
(
route
,
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
context
'when ref contains a dot'
do
context
'when ref contains a dot'
do
...
@@ -1839,7 +1839,7 @@ describe API::Commits do
...
@@ -1839,7 +1839,7 @@ describe API::Commits do
it
'returns the correct merge request'
do
it
'returns the correct merge request'
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/merge_requests"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/merge_requests"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
[
0
][
'id'
]).
to
eq
(
merged_mr
.
id
)
expect
(
json_response
[
0
][
'id'
]).
to
eq
(
merged_mr
.
id
)
...
@@ -1850,13 +1850,13 @@ describe API::Commits do
...
@@ -1850,13 +1850,13 @@ describe API::Commits do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/merge_requests"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/merge_requests"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
it
'responds 404 when the commit does not exist'
do
it
'responds 404 when the commit does not exist'
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/a7d26f00c35b/merge_requests"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/a7d26f00c35b/merge_requests"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
context
'public project'
do
context
'public project'
do
...
@@ -1866,7 +1866,7 @@ describe API::Commits do
...
@@ -1866,7 +1866,7 @@ describe API::Commits do
it
'responds 403 when only members are allowed to read merge requests'
do
it
'responds 403 when only members are allowed to read merge requests'
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/merge_requests"
,
non_member
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/merge_requests"
,
non_member
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -1900,7 +1900,7 @@ describe API::Commits do
...
@@ -1900,7 +1900,7 @@ describe API::Commits do
it
'returns correct JSON'
do
it
'returns correct JSON'
do
get
api
(
route
,
current_user
)
get
api
(
route
,
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'gpg_key_id'
]).
to
eq
(
commit
.
signature
.
gpg_key_id
)
expect
(
json_response
[
'gpg_key_id'
]).
to
eq
(
commit
.
signature
.
gpg_key_id
)
expect
(
json_response
[
'gpg_key_subkey_id'
]).
to
eq
(
commit
.
signature
.
gpg_key_subkey_id
)
expect
(
json_response
[
'gpg_key_subkey_id'
]).
to
eq
(
commit
.
signature
.
gpg_key_subkey_id
)
expect
(
json_response
[
'gpg_key_primary_keyid'
]).
to
eq
(
commit
.
signature
.
gpg_key_primary_keyid
)
expect
(
json_response
[
'gpg_key_primary_keyid'
]).
to
eq
(
commit
.
signature
.
gpg_key_primary_keyid
)
...
...
spec/requests/api/deploy_keys_spec.rb
View file @
ad35e902
...
@@ -51,7 +51,7 @@ describe API::DeployKeys do
...
@@ -51,7 +51,7 @@ describe API::DeployKeys do
it
'returns array of ssh keys'
do
it
'returns array of ssh keys'
do
get
api
(
"/projects/
#{
project
.
id
}
/deploy_keys"
,
admin
)
get
api
(
"/projects/
#{
project
.
id
}
/deploy_keys"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
deploy_key
.
title
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
deploy_key
.
title
)
...
@@ -62,14 +62,14 @@ describe API::DeployKeys do
...
@@ -62,14 +62,14 @@ describe API::DeployKeys do
it
'returns a single key'
do
it
'returns a single key'
do
get
api
(
"/projects/
#{
project
.
id
}
/deploy_keys/
#{
deploy_key
.
id
}
"
,
admin
)
get
api
(
"/projects/
#{
project
.
id
}
/deploy_keys/
#{
deploy_key
.
id
}
"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'title'
]).
to
eq
(
deploy_key
.
title
)
expect
(
json_response
[
'title'
]).
to
eq
(
deploy_key
.
title
)
end
end
it
'returns 404 Not Found with invalid ID'
do
it
'returns 404 Not Found with invalid ID'
do
get
api
(
"/projects/
#{
project
.
id
}
/deploy_keys/404"
,
admin
)
get
api
(
"/projects/
#{
project
.
id
}
/deploy_keys/404"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -77,14 +77,14 @@ describe API::DeployKeys do
...
@@ -77,14 +77,14 @@ describe API::DeployKeys do
it
'does not create an invalid ssh key'
do
it
'does not create an invalid ssh key'
do
post
api
(
"/projects/
#{
project
.
id
}
/deploy_keys"
,
admin
),
params:
{
title:
'invalid key'
}
post
api
(
"/projects/
#{
project
.
id
}
/deploy_keys"
,
admin
),
params:
{
title:
'invalid key'
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'error'
]).
to
eq
(
'key is missing'
)
expect
(
json_response
[
'error'
]).
to
eq
(
'key is missing'
)
end
end
it
'does not create a key without title'
do
it
'does not create a key without title'
do
post
api
(
"/projects/
#{
project
.
id
}
/deploy_keys"
,
admin
),
params:
{
key:
'some key'
}
post
api
(
"/projects/
#{
project
.
id
}
/deploy_keys"
,
admin
),
params:
{
key:
'some key'
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'error'
]).
to
eq
(
'title is missing'
)
expect
(
json_response
[
'error'
]).
to
eq
(
'title is missing'
)
end
end
...
@@ -105,7 +105,7 @@ describe API::DeployKeys do
...
@@ -105,7 +105,7 @@ describe API::DeployKeys do
post
api
(
"/projects/
#{
project
.
id
}
/deploy_keys"
,
admin
),
params:
{
key:
deploy_key
.
key
,
title:
deploy_key
.
title
}
post
api
(
"/projects/
#{
project
.
id
}
/deploy_keys"
,
admin
),
params:
{
key:
deploy_key
.
key
,
title:
deploy_key
.
title
}
end
.
not_to
change
{
project
.
deploy_keys
.
count
}
end
.
not_to
change
{
project
.
deploy_keys
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
end
end
it
'joins an existing ssh key to a new project'
do
it
'joins an existing ssh key to a new project'
do
...
@@ -113,7 +113,7 @@ describe API::DeployKeys do
...
@@ -113,7 +113,7 @@ describe API::DeployKeys do
post
api
(
"/projects/
#{
project2
.
id
}
/deploy_keys"
,
admin
),
params:
{
key:
deploy_key
.
key
,
title:
deploy_key
.
title
}
post
api
(
"/projects/
#{
project2
.
id
}
/deploy_keys"
,
admin
),
params:
{
key:
deploy_key
.
key
,
title:
deploy_key
.
title
}
end
.
to
change
{
project2
.
deploy_keys
.
count
}.
by
(
1
)
end
.
to
change
{
project2
.
deploy_keys
.
count
}.
by
(
1
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
end
end
it
'accepts can_push parameter'
do
it
'accepts can_push parameter'
do
...
@@ -121,7 +121,7 @@ describe API::DeployKeys do
...
@@ -121,7 +121,7 @@ describe API::DeployKeys do
post
api
(
"/projects/
#{
project
.
id
}
/deploy_keys"
,
admin
),
params:
key_attrs
post
api
(
"/projects/
#{
project
.
id
}
/deploy_keys"
,
admin
),
params:
key_attrs
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'can_push'
]).
to
eq
(
true
)
expect
(
json_response
[
'can_push'
]).
to
eq
(
true
)
end
end
end
end
...
@@ -139,7 +139,7 @@ describe API::DeployKeys do
...
@@ -139,7 +139,7 @@ describe API::DeployKeys do
it
'does not update a public deploy key'
do
it
'does not update a public deploy key'
do
expect
{
subject
}.
not_to
change
(
deploy_key
,
:title
)
expect
{
subject
}.
not_to
change
(
deploy_key
,
:title
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -151,12 +151,12 @@ describe API::DeployKeys do
...
@@ -151,12 +151,12 @@ describe API::DeployKeys do
it
'updates the title of the deploy key'
do
it
'updates the title of the deploy key'
do
expect
{
subject
}.
to
change
{
deploy_key
.
reload
.
title
}.
to
'new title'
expect
{
subject
}.
to
change
{
deploy_key
.
reload
.
title
}.
to
'new title'
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'updates can_push of deploy_keys_project'
do
it
'updates can_push of deploy_keys_project'
do
expect
{
subject
}.
to
change
{
deploy_keys_project
.
reload
.
can_push
}.
from
(
false
).
to
(
true
)
expect
{
subject
}.
to
change
{
deploy_keys_project
.
reload
.
can_push
}.
from
(
false
).
to
(
true
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
...
@@ -169,12 +169,12 @@ describe API::DeployKeys do
...
@@ -169,12 +169,12 @@ describe API::DeployKeys do
it
'updates the title of the deploy key'
do
it
'updates the title of the deploy key'
do
expect
{
subject
}.
to
change
{
deploy_key
.
reload
.
title
}.
to
'new title'
expect
{
subject
}.
to
change
{
deploy_key
.
reload
.
title
}.
to
'new title'
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'updates can_push of deploy_keys_project'
do
it
'updates can_push of deploy_keys_project'
do
expect
{
subject
}.
to
change
{
deploy_keys_project
.
reload
.
can_push
}.
from
(
false
).
to
(
true
)
expect
{
subject
}.
to
change
{
deploy_keys_project
.
reload
.
can_push
}.
from
(
false
).
to
(
true
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
context
'invalid title'
do
context
'invalid title'
do
...
@@ -182,7 +182,7 @@ describe API::DeployKeys do
...
@@ -182,7 +182,7 @@ describe API::DeployKeys do
it
'does not update the title of the deploy key'
do
it
'does not update the title of the deploy key'
do
expect
{
subject
}.
not_to
change
{
deploy_key
.
reload
.
title
}
expect
{
subject
}.
not_to
change
{
deploy_key
.
reload
.
title
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
end
end
...
@@ -200,12 +200,12 @@ describe API::DeployKeys do
...
@@ -200,12 +200,12 @@ describe API::DeployKeys do
it
'updates the title of the deploy key'
do
it
'updates the title of the deploy key'
do
expect
{
subject
}.
to
change
{
deploy_key
.
reload
.
title
}.
to
'new title'
expect
{
subject
}.
to
change
{
deploy_key
.
reload
.
title
}.
to
'new title'
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'updates can_push of deploy_keys_project'
do
it
'updates can_push of deploy_keys_project'
do
expect
{
subject
}.
to
change
{
deploy_keys_project
.
reload
.
can_push
}.
from
(
false
).
to
(
true
)
expect
{
subject
}.
to
change
{
deploy_keys_project
.
reload
.
can_push
}.
from
(
false
).
to
(
true
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
end
end
...
@@ -222,12 +222,12 @@ describe API::DeployKeys do
...
@@ -222,12 +222,12 @@ describe API::DeployKeys do
it
'does not update the title of the deploy key'
do
it
'does not update the title of the deploy key'
do
expect
{
subject
}.
not_to
change
{
deploy_key
.
reload
.
title
}
expect
{
subject
}.
not_to
change
{
deploy_key
.
reload
.
title
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'updates can_push of deploy_keys_project'
do
it
'updates can_push of deploy_keys_project'
do
expect
{
subject
}.
to
change
{
deploy_keys_project
.
reload
.
can_push
}.
from
(
false
).
to
(
true
)
expect
{
subject
}.
to
change
{
deploy_keys_project
.
reload
.
can_push
}.
from
(
false
).
to
(
true
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
end
end
...
@@ -242,7 +242,7 @@ describe API::DeployKeys do
...
@@ -242,7 +242,7 @@ describe API::DeployKeys do
expect
do
expect
do
delete
api
(
"/projects/
#{
project
.
id
}
/deploy_keys/
#{
deploy_key
.
id
}
"
,
admin
)
delete
api
(
"/projects/
#{
project
.
id
}
/deploy_keys/
#{
deploy_key
.
id
}
"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
.
to
change
{
project
.
deploy_keys
.
count
}.
by
(
-
1
)
end
.
to
change
{
project
.
deploy_keys
.
count
}.
by
(
-
1
)
end
end
...
@@ -251,7 +251,7 @@ describe API::DeployKeys do
...
@@ -251,7 +251,7 @@ describe API::DeployKeys do
expect
do
expect
do
delete
api
(
"/projects/
#{
project
.
id
}
/deploy_keys/
#{
deploy_key
.
id
}
"
,
admin
)
delete
api
(
"/projects/
#{
project
.
id
}
/deploy_keys/
#{
deploy_key
.
id
}
"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
.
not_to
change
{
DeployKey
.
count
}
end
.
not_to
change
{
DeployKey
.
count
}
end
end
end
end
...
@@ -264,7 +264,7 @@ describe API::DeployKeys do
...
@@ -264,7 +264,7 @@ describe API::DeployKeys do
expect
do
expect
do
delete
api
(
"/projects/
#{
project
.
id
}
/deploy_keys/
#{
deploy_key
.
id
}
"
,
admin
)
delete
api
(
"/projects/
#{
project
.
id
}
/deploy_keys/
#{
deploy_key
.
id
}
"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
.
to
change
{
DeployKey
.
count
}.
by
(
-
1
)
end
.
to
change
{
DeployKey
.
count
}.
by
(
-
1
)
end
end
end
end
...
@@ -278,7 +278,7 @@ describe API::DeployKeys do
...
@@ -278,7 +278,7 @@ describe API::DeployKeys do
expect
do
expect
do
delete
api
(
"/projects/
#{
project
.
id
}
/deploy_keys/
#{
deploy_key
.
id
}
"
,
admin
)
delete
api
(
"/projects/
#{
project
.
id
}
/deploy_keys/
#{
deploy_key
.
id
}
"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
.
not_to
change
{
DeployKey
.
count
}
end
.
not_to
change
{
DeployKey
.
count
}
end
end
end
end
...
@@ -287,7 +287,7 @@ describe API::DeployKeys do
...
@@ -287,7 +287,7 @@ describe API::DeployKeys do
it
'returns 404 Not Found with invalid ID'
do
it
'returns 404 Not Found with invalid ID'
do
delete
api
(
"/projects/
#{
project
.
id
}
/deploy_keys/404"
,
admin
)
delete
api
(
"/projects/
#{
project
.
id
}
/deploy_keys/404"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it_behaves_like
'412 response'
do
it_behaves_like
'412 response'
do
...
@@ -304,7 +304,7 @@ describe API::DeployKeys do
...
@@ -304,7 +304,7 @@ describe API::DeployKeys do
post
api
(
"/projects/
#{
project2
.
id
}
/deploy_keys/
#{
deploy_key
.
id
}
/enable"
,
admin
)
post
api
(
"/projects/
#{
project2
.
id
}
/deploy_keys/
#{
deploy_key
.
id
}
/enable"
,
admin
)
end
.
to
change
{
project2
.
deploy_keys
.
count
}.
from
(
0
).
to
(
1
)
end
.
to
change
{
project2
.
deploy_keys
.
count
}.
from
(
0
).
to
(
1
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'id'
]).
to
eq
(
deploy_key
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
deploy_key
.
id
)
end
end
end
end
...
@@ -313,7 +313,7 @@ describe API::DeployKeys do
...
@@ -313,7 +313,7 @@ describe API::DeployKeys do
it
'returns a 404 error'
do
it
'returns a 404 error'
do
post
api
(
"/projects/
#{
project2
.
id
}
/deploy_keys/
#{
deploy_key
.
id
}
/enable"
,
user
)
post
api
(
"/projects/
#{
project2
.
id
}
/deploy_keys/
#{
deploy_key
.
id
}
/enable"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
...
spec/requests/api/deployments_spec.rb
View file @
ad35e902
...
@@ -20,7 +20,7 @@ describe API::Deployments do
...
@@ -20,7 +20,7 @@ describe API::Deployments do
it
'returns projects deployments sorted by id asc'
do
it
'returns projects deployments sorted by id asc'
do
get
api
(
"/projects/
#{
project
.
id
}
/deployments"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/deployments"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
3
)
expect
(
json_response
.
size
).
to
eq
(
3
)
...
@@ -74,7 +74,7 @@ describe API::Deployments do
...
@@ -74,7 +74,7 @@ describe API::Deployments do
let
(
:order_by
)
{
'wrong_sorting_value'
}
let
(
:order_by
)
{
'wrong_sorting_value'
}
it
'returns error'
do
it
'returns error'
do
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
...
@@ -82,7 +82,7 @@ describe API::Deployments do
...
@@ -82,7 +82,7 @@ describe API::Deployments do
let
(
:sort
)
{
'wrong_sorting_direction'
}
let
(
:sort
)
{
'wrong_sorting_direction'
}
it
'returns error'
do
it
'returns error'
do
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
end
end
...
@@ -92,7 +92,7 @@ describe API::Deployments do
...
@@ -92,7 +92,7 @@ describe API::Deployments do
it
'returns a 404 status code'
do
it
'returns a 404 status code'
do
get
api
(
"/projects/
#{
project
.
id
}
/deployments"
,
non_member
)
get
api
(
"/projects/
#{
project
.
id
}
/deployments"
,
non_member
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
@@ -105,7 +105,7 @@ describe API::Deployments do
...
@@ -105,7 +105,7 @@ describe API::Deployments do
it
'returns the projects deployment'
do
it
'returns the projects deployment'
do
get
api
(
"/projects/
#{
project
.
id
}
/deployments/
#{
deployment
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/deployments/
#{
deployment
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'sha'
]).
to
match
/\A\h{40}\z/
expect
(
json_response
[
'sha'
]).
to
match
/\A\h{40}\z/
expect
(
json_response
[
'id'
]).
to
eq
(
deployment
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
deployment
.
id
)
end
end
...
@@ -115,7 +115,7 @@ describe API::Deployments do
...
@@ -115,7 +115,7 @@ describe API::Deployments do
it
'returns a 404 status code'
do
it
'returns a 404 status code'
do
get
api
(
"/projects/
#{
project
.
id
}
/deployments/
#{
deployment
.
id
}
"
,
non_member
)
get
api
(
"/projects/
#{
project
.
id
}
/deployments/
#{
deployment
.
id
}
"
,
non_member
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
@@ -159,7 +159,7 @@ describe API::Deployments do
...
@@ -159,7 +159,7 @@ describe API::Deployments do
}
}
)
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'sha'
]).
to
eq
(
sha
)
expect
(
json_response
[
'sha'
]).
to
eq
(
sha
)
expect
(
json_response
[
'ref'
]).
to
eq
(
'master'
)
expect
(
json_response
[
'ref'
]).
to
eq
(
'master'
)
...
@@ -178,7 +178,7 @@ describe API::Deployments do
...
@@ -178,7 +178,7 @@ describe API::Deployments do
}
}
)
)
expect
(
response
).
to
have_gitlab_http_status
(
500
)
expect
(
response
).
to
have_gitlab_http_status
(
:internal_server_error
)
end
end
it
'links any merged merge requests to the deployment'
,
:sidekiq_inline
do
it
'links any merged merge requests to the deployment'
,
:sidekiq_inline
do
...
@@ -228,7 +228,7 @@ describe API::Deployments do
...
@@ -228,7 +228,7 @@ describe API::Deployments do
}
}
)
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'sha'
]).
to
eq
(
sha
)
expect
(
json_response
[
'sha'
]).
to
eq
(
sha
)
expect
(
json_response
[
'ref'
]).
to
eq
(
'master'
)
expect
(
json_response
[
'ref'
]).
to
eq
(
'master'
)
...
@@ -312,7 +312,7 @@ describe API::Deployments do
...
@@ -312,7 +312,7 @@ describe API::Deployments do
}
}
)
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
@@ -341,7 +341,7 @@ describe API::Deployments do
...
@@ -341,7 +341,7 @@ describe API::Deployments do
params:
{
status:
'success'
}
params:
{
status:
'success'
}
)
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
it
'updates a deployment without an associated build'
do
it
'updates a deployment without an associated build'
do
...
@@ -350,7 +350,7 @@ describe API::Deployments do
...
@@ -350,7 +350,7 @@ describe API::Deployments do
params:
{
status:
'success'
}
params:
{
status:
'success'
}
)
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'status'
]).
to
eq
(
'success'
)
expect
(
json_response
[
'status'
]).
to
eq
(
'success'
)
end
end
...
@@ -390,7 +390,7 @@ describe API::Deployments do
...
@@ -390,7 +390,7 @@ describe API::Deployments do
params:
{
status:
'success'
}
params:
{
status:
'success'
}
)
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
it
'updates a deployment without an associated build'
do
it
'updates a deployment without an associated build'
do
...
@@ -399,7 +399,7 @@ describe API::Deployments do
...
@@ -399,7 +399,7 @@ describe API::Deployments do
params:
{
status:
'success'
}
params:
{
status:
'success'
}
)
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'status'
]).
to
eq
(
'success'
)
expect
(
json_response
[
'status'
]).
to
eq
(
'success'
)
end
end
end
end
...
@@ -411,7 +411,7 @@ describe API::Deployments do
...
@@ -411,7 +411,7 @@ describe API::Deployments do
params:
{
status:
'success'
}
params:
{
status:
'success'
}
)
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
@@ -428,7 +428,7 @@ describe API::Deployments do
...
@@ -428,7 +428,7 @@ describe API::Deployments do
it
'returns a 404 status code'
do
it
'returns a 404 status code'
do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -443,7 +443,7 @@ describe API::Deployments do
...
@@ -443,7 +443,7 @@ describe API::Deployments do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
.
map
{
|
d
|
d
[
'id'
]
}).
to
contain_exactly
(
merge_request1
.
id
,
merge_request2
.
id
)
expect
(
json_response
.
map
{
|
d
|
d
[
'id'
]
}).
to
contain_exactly
(
merge_request1
.
id
,
merge_request2
.
id
)
end
end
...
@@ -451,7 +451,7 @@ describe API::Deployments do
...
@@ -451,7 +451,7 @@ describe API::Deployments do
it
'returns an empty array'
do
it
'returns an empty array'
do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
eq
([])
expect
(
json_response
).
to
eq
([])
end
end
end
end
...
@@ -468,7 +468,7 @@ describe API::Deployments do
...
@@ -468,7 +468,7 @@ describe API::Deployments do
it
'succeeds'
,
:aggregate_failures
do
it
'succeeds'
,
:aggregate_failures
do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
size
).
to
eq
(
1
)
end
end
...
...
spec/requests/api/discussions_spec.rb
View file @
ad35e902
...
@@ -58,7 +58,7 @@ describe API::Discussions do
...
@@ -58,7 +58,7 @@ describe API::Discussions do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
noteable
[
'iid'
]
}
/discussions"
,
user
),
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
noteable
[
'iid'
]
}
/discussions"
,
user
),
params:
{
body:
'hi!'
,
position:
position
}
params:
{
body:
'hi!'
,
position:
position
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
end
end
...
...
spec/requests/api/doorkeeper_access_spec.rb
View file @
ad35e902
...
@@ -10,7 +10,7 @@ describe 'doorkeeper access' do
...
@@ -10,7 +10,7 @@ describe 'doorkeeper access' do
describe
"unauthenticated"
do
describe
"unauthenticated"
do
it
"returns authentication success"
do
it
"returns authentication success"
do
get
api
(
"/user"
),
params:
{
access_token:
token
.
token
}
get
api
(
"/user"
),
params:
{
access_token:
token
.
token
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
include_examples
'user login request with unique ip limit'
do
include_examples
'user login request with unique ip limit'
do
...
@@ -23,14 +23,14 @@ describe 'doorkeeper access' do
...
@@ -23,14 +23,14 @@ describe 'doorkeeper access' do
describe
"when token invalid"
do
describe
"when token invalid"
do
it
"returns authentication error"
do
it
"returns authentication error"
do
get
api
(
"/user"
),
params:
{
access_token:
"123a"
}
get
api
(
"/user"
),
params:
{
access_token:
"123a"
}
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
describe
"authorization by OAuth token"
do
describe
"authorization by OAuth token"
do
it
"returns authentication success"
do
it
"returns authentication success"
do
get
api
(
"/user"
,
user
)
get
api
(
"/user"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
include_examples
'user login request with unique ip limit'
do
include_examples
'user login request with unique ip limit'
do
...
@@ -44,7 +44,7 @@ describe 'doorkeeper access' do
...
@@ -44,7 +44,7 @@ describe 'doorkeeper access' do
it
'returns 403 response'
do
it
'returns 403 response'
do
get
api
(
"/user"
),
params:
{
access_token:
token
.
token
}
get
api
(
"/user"
),
params:
{
access_token:
token
.
token
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
...
spec/requests/api/environments_spec.rb
View file @
ad35e902
...
@@ -27,7 +27,7 @@ describe API::Environments do
...
@@ -27,7 +27,7 @@ describe API::Environments do
get
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
size
).
to
eq
(
1
)
...
@@ -43,7 +43,7 @@ describe API::Environments do
...
@@ -43,7 +43,7 @@ describe API::Environments do
it
'returns environment by name'
do
it
'returns environment by name'
do
get
api
(
"/projects/
#{
project
.
id
}
/environments?name=
#{
environment
.
name
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/environments?name=
#{
environment
.
name
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
size
).
to
eq
(
1
)
...
@@ -53,7 +53,7 @@ describe API::Environments do
...
@@ -53,7 +53,7 @@ describe API::Environments do
it
'returns no environment by non-existent name'
do
it
'returns no environment by non-existent name'
do
get
api
(
"/projects/
#{
project
.
id
}
/environments?name=test"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/environments?name=test"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
0
)
expect
(
json_response
.
size
).
to
eq
(
0
)
...
@@ -62,7 +62,7 @@ describe API::Environments do
...
@@ -62,7 +62,7 @@ describe API::Environments do
it
'returns environments by name_like'
do
it
'returns environments by name_like'
do
get
api
(
"/projects/
#{
project
.
id
}
/environments?search=envir"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/environments?search=envir"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
2
)
expect
(
json_response
.
size
).
to
eq
(
2
)
...
@@ -71,7 +71,7 @@ describe API::Environments do
...
@@ -71,7 +71,7 @@ describe API::Environments do
it
'returns no environment by non-existent name_like'
do
it
'returns no environment by non-existent name_like'
do
get
api
(
"/projects/
#{
project
.
id
}
/environments?search=test"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/environments?search=test"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
0
)
expect
(
json_response
.
size
).
to
eq
(
0
)
...
@@ -83,7 +83,7 @@ describe API::Environments do
...
@@ -83,7 +83,7 @@ describe API::Environments do
it
'returns a 404 status code'
do
it
'returns a 404 status code'
do
get
api
(
"/projects/
#{
project
.
id
}
/environments"
,
non_member
)
get
api
(
"/projects/
#{
project
.
id
}
/environments"
,
non_member
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
@@ -93,7 +93,7 @@ describe API::Environments do
...
@@ -93,7 +93,7 @@ describe API::Environments do
it
'creates a environment with valid params'
do
it
'creates a environment with valid params'
do
post
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
),
params:
{
name:
"mepmep"
}
post
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
),
params:
{
name:
"mepmep"
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'name'
]).
to
eq
(
'mepmep'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'mepmep'
)
expect
(
json_response
[
'slug'
]).
to
eq
(
'mepmep'
)
expect
(
json_response
[
'slug'
]).
to
eq
(
'mepmep'
)
expect
(
json_response
[
'external'
]).
to
be
nil
expect
(
json_response
[
'external'
]).
to
be
nil
...
@@ -102,19 +102,19 @@ describe API::Environments do
...
@@ -102,19 +102,19 @@ describe API::Environments do
it
'requires name to be passed'
do
it
'requires name to be passed'
do
post
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
),
params:
{
external_url:
'test.gitlab.com'
}
post
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
),
params:
{
external_url:
'test.gitlab.com'
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
'returns a 400 if environment already exists'
do
it
'returns a 400 if environment already exists'
do
post
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
),
params:
{
name:
environment
.
name
}
post
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
),
params:
{
name:
environment
.
name
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
'returns a 400 if slug is specified'
do
it
'returns a 400 if slug is specified'
do
post
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
),
params:
{
name:
"foo"
,
slug:
"foo"
}
post
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
),
params:
{
name:
"foo"
,
slug:
"foo"
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
"error"
]).
to
eq
(
"slug is automatically generated and cannot be changed"
)
expect
(
json_response
[
"error"
]).
to
eq
(
"slug is automatically generated and cannot be changed"
)
end
end
end
end
...
@@ -123,7 +123,7 @@ describe API::Environments do
...
@@ -123,7 +123,7 @@ describe API::Environments do
it
'rejects the request'
do
it
'rejects the request'
do
post
api
(
"/projects/
#{
project
.
id
}
/environments"
,
non_member
),
params:
{
name:
'gitlab.com'
}
post
api
(
"/projects/
#{
project
.
id
}
/environments"
,
non_member
),
params:
{
name:
'gitlab.com'
}
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
'returns a 400 when the required params are missing'
do
it
'returns a 400 when the required params are missing'
do
...
@@ -138,7 +138,7 @@ describe API::Environments do
...
@@ -138,7 +138,7 @@ describe API::Environments do
put
api
(
"/projects/
#{
project
.
id
}
/environments/
#{
environment
.
id
}
"
,
user
),
put
api
(
"/projects/
#{
project
.
id
}
/environments/
#{
environment
.
id
}
"
,
user
),
params:
{
name:
'Mepmep'
,
external_url:
url
}
params:
{
name:
'Mepmep'
,
external_url:
url
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'name'
]).
to
eq
(
'Mepmep'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'Mepmep'
)
expect
(
json_response
[
'external_url'
]).
to
eq
(
url
)
expect
(
json_response
[
'external_url'
]).
to
eq
(
url
)
end
end
...
@@ -148,7 +148,7 @@ describe API::Environments do
...
@@ -148,7 +148,7 @@ describe API::Environments do
api_url
=
api
(
"/projects/
#{
project
.
id
}
/environments/
#{
environment
.
id
}
"
,
user
)
api_url
=
api
(
"/projects/
#{
project
.
id
}
/environments/
#{
environment
.
id
}
"
,
user
)
put
api_url
,
params:
{
slug:
slug
+
"-foo"
}
put
api_url
,
params:
{
slug:
slug
+
"-foo"
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
"error"
]).
to
eq
(
"slug is automatically generated and cannot be changed"
)
expect
(
json_response
[
"error"
]).
to
eq
(
"slug is automatically generated and cannot be changed"
)
end
end
...
@@ -157,7 +157,7 @@ describe API::Environments do
...
@@ -157,7 +157,7 @@ describe API::Environments do
put
api
(
"/projects/
#{
project
.
id
}
/environments/
#{
environment
.
id
}
"
,
user
),
put
api
(
"/projects/
#{
project
.
id
}
/environments/
#{
environment
.
id
}
"
,
user
),
params:
{
name:
'Mepmep'
}
params:
{
name:
'Mepmep'
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'name'
]).
to
eq
(
'Mepmep'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'Mepmep'
)
expect
(
json_response
[
'external_url'
]).
to
eq
(
url
)
expect
(
json_response
[
'external_url'
]).
to
eq
(
url
)
end
end
...
@@ -165,7 +165,7 @@ describe API::Environments do
...
@@ -165,7 +165,7 @@ describe API::Environments do
it
'returns a 404 if the environment does not exist'
do
it
'returns a 404 if the environment does not exist'
do
put
api
(
"/projects/
#{
project
.
id
}
/environments/12345"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/environments/12345"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -174,13 +174,13 @@ describe API::Environments do
...
@@ -174,13 +174,13 @@ describe API::Environments do
it
'returns a 200 for an existing environment'
do
it
'returns a 200 for an existing environment'
do
delete
api
(
"/projects/
#{
project
.
id
}
/environments/
#{
environment
.
id
}
"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/environments/
#{
environment
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
end
it
'returns a 404 for non existing id'
do
it
'returns a 404 for non existing id'
do
delete
api
(
"/projects/
#{
project
.
id
}
/environments/12345"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/environments/12345"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
end
end
...
@@ -193,7 +193,7 @@ describe API::Environments do
...
@@ -193,7 +193,7 @@ describe API::Environments do
it
'rejects the request'
do
it
'rejects the request'
do
delete
api
(
"/projects/
#{
project
.
id
}
/environments/
#{
environment
.
id
}
"
,
non_member
)
delete
api
(
"/projects/
#{
project
.
id
}
/environments/
#{
environment
.
id
}
"
,
non_member
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
@@ -208,7 +208,7 @@ describe API::Environments do
...
@@ -208,7 +208,7 @@ describe API::Environments do
end
end
it
'returns a 200'
do
it
'returns a 200'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'actually stops the environment'
do
it
'actually stops the environment'
do
...
@@ -219,7 +219,7 @@ describe API::Environments do
...
@@ -219,7 +219,7 @@ describe API::Environments do
it
'returns a 404 for non existing id'
do
it
'returns a 404 for non existing id'
do
post
api
(
"/projects/
#{
project
.
id
}
/environments/12345/stop"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/environments/12345/stop"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
end
end
end
end
...
@@ -228,7 +228,7 @@ describe API::Environments do
...
@@ -228,7 +228,7 @@ describe API::Environments do
it
'rejects the request'
do
it
'rejects the request'
do
post
api
(
"/projects/
#{
project
.
id
}
/environments/
#{
environment
.
id
}
/stop"
,
non_member
)
post
api
(
"/projects/
#{
project
.
id
}
/environments/
#{
environment
.
id
}
/stop"
,
non_member
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
@@ -240,7 +240,7 @@ describe API::Environments do
...
@@ -240,7 +240,7 @@ describe API::Environments do
get
api
(
"/projects/
#{
project
.
id
}
/environments/
#{
environment
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/environments/
#{
environment
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/environment'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/environment'
)
end
end
end
end
...
@@ -249,7 +249,7 @@ describe API::Environments do
...
@@ -249,7 +249,7 @@ describe API::Environments do
it
'returns a 404 status code'
do
it
'returns a 404 status code'
do
get
api
(
"/projects/
#{
project
.
id
}
/environments/
#{
environment
.
id
}
"
,
non_member
)
get
api
(
"/projects/
#{
project
.
id
}
/environments/
#{
environment
.
id
}
"
,
non_member
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
...
spec/requests/api/events_spec.rb
View file @
ad35e902
...
@@ -16,7 +16,7 @@ describe API::Events do
...
@@ -16,7 +16,7 @@ describe API::Events do
it
'returns authentication error'
do
it
'returns authentication error'
do
get
api
(
'/events'
)
get
api
(
'/events'
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
...
@@ -24,7 +24,7 @@ describe API::Events do
...
@@ -24,7 +24,7 @@ describe API::Events do
it
'returns users events'
do
it
'returns users events'
do
get
api
(
'/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31'
,
user
)
get
api
(
'/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31'
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
size
).
to
eq
(
1
)
...
@@ -36,7 +36,7 @@ describe API::Events do
...
@@ -36,7 +36,7 @@ describe API::Events do
get
api
(
'/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31&scope=all'
,
user
)
get
api
(
'/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31&scope=all'
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
2
)
expect
(
json_response
.
size
).
to
eq
(
2
)
...
@@ -50,7 +50,7 @@ describe API::Events do
...
@@ -50,7 +50,7 @@ describe API::Events do
it
'returns users events'
do
it
'returns users events'
do
get
api
(
'/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31'
,
personal_access_token:
token
)
get
api
(
'/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31'
,
personal_access_token:
token
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
size
).
to
eq
(
1
)
...
@@ -63,7 +63,7 @@ describe API::Events do
...
@@ -63,7 +63,7 @@ describe API::Events do
it
'returns a "403" response'
do
it
'returns a "403" response'
do
get
api
(
'/events'
,
personal_access_token:
token_without_scopes
)
get
api
(
'/events'
,
personal_access_token:
token_without_scopes
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -76,7 +76,7 @@ describe API::Events do
...
@@ -76,7 +76,7 @@ describe API::Events do
get
api
(
"/users/
#{
user
.
id
}
/events"
,
non_member
)
get
api
(
"/users/
#{
user
.
id
}
/events"
,
non_member
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
be_empty
expect
(
json_response
).
to
be_empty
end
end
end
end
...
@@ -90,7 +90,7 @@ describe API::Events do
...
@@ -90,7 +90,7 @@ describe API::Events do
get
api
(
"/users/
#{
user
.
id
}
/events"
,
personal_access_token:
non_member_token
)
get
api
(
"/users/
#{
user
.
id
}
/events"
,
personal_access_token:
non_member_token
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
be_empty
expect
(
json_response
).
to
be_empty
end
end
end
end
...
@@ -99,7 +99,7 @@ describe API::Events do
...
@@ -99,7 +99,7 @@ describe API::Events do
it
'accepts a username'
do
it
'accepts a username'
do
get
api
(
"/users/
#{
user
.
username
}
/events"
,
user
)
get
api
(
"/users/
#{
user
.
username
}
/events"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
size
).
to
eq
(
1
)
...
@@ -108,7 +108,7 @@ describe API::Events do
...
@@ -108,7 +108,7 @@ describe API::Events do
it
'returns the events'
do
it
'returns the events'
do
get
api
(
"/users/
#{
user
.
id
}
/events"
,
user
)
get
api
(
"/users/
#{
user
.
id
}
/events"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
size
).
to
eq
(
1
)
...
@@ -127,7 +127,7 @@ describe API::Events do
...
@@ -127,7 +127,7 @@ describe API::Events do
end
end
it
'responds with HTTP 200 OK'
do
it
'responds with HTTP 200 OK'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'includes the push payload as a Hash'
do
it
'includes the push payload as a Hash'
do
...
@@ -177,7 +177,7 @@ describe API::Events do
...
@@ -177,7 +177,7 @@ describe API::Events do
it
'returns no user events'
do
it
'returns no user events'
do
get
api
(
"/users/
#{
user
.
username
}
/events?scope=all"
)
get
api
(
"/users/
#{
user
.
username
}
/events?scope=all"
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
0
)
expect
(
json_response
.
size
).
to
eq
(
0
)
end
end
...
@@ -188,7 +188,7 @@ describe API::Events do
...
@@ -188,7 +188,7 @@ describe API::Events do
it
'returns a 404 error if not found'
do
it
'returns a 404 error if not found'
do
get
api
(
'/users/42/events'
,
user
)
get
api
(
'/users/42/events'
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 User Not Found'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 User Not Found'
)
end
end
end
end
...
...
spec/requests/api/features_spec.rb
View file @
ad35e902
...
@@ -46,19 +46,19 @@ describe API::Features do
...
@@ -46,19 +46,19 @@ describe API::Features do
it
'returns a 401 for anonymous users'
do
it
'returns a 401 for anonymous users'
do
get
api
(
'/features'
)
get
api
(
'/features'
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
it
'returns a 403 for users'
do
it
'returns a 403 for users'
do
get
api
(
'/features'
,
user
)
get
api
(
'/features'
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
it
'returns the feature list for admins'
do
it
'returns the feature list for admins'
do
get
api
(
'/features'
,
admin
)
get
api
(
'/features'
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
match_array
(
expected_features
)
expect
(
json_response
).
to
match_array
(
expected_features
)
end
end
end
end
...
@@ -70,20 +70,20 @@ describe API::Features do
...
@@ -70,20 +70,20 @@ describe API::Features do
it
'returns a 401 for anonymous users'
do
it
'returns a 401 for anonymous users'
do
post
api
(
"/features/
#{
feature_name
}
"
)
post
api
(
"/features/
#{
feature_name
}
"
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
it
'returns a 403 for users'
do
it
'returns a 403 for users'
do
post
api
(
"/features/
#{
feature_name
}
"
,
user
)
post
api
(
"/features/
#{
feature_name
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
context
'when passed value=true'
do
context
'when passed value=true'
do
it
'creates an enabled feature'
do
it
'creates an enabled feature'
do
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
}
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
to
eq
(
expect
(
json_response
).
to
eq
(
'name'
=>
'my_feature'
,
'name'
=>
'my_feature'
,
'state'
=>
'on'
,
'state'
=>
'on'
,
...
@@ -93,7 +93,7 @@ describe API::Features do
...
@@ -93,7 +93,7 @@ describe API::Features do
it
'creates an enabled feature for the given Flipper group when passed feature_group=perf_team'
do
it
'creates an enabled feature for the given Flipper group when passed feature_group=perf_team'
do
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
feature_group:
'perf_team'
}
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
feature_group:
'perf_team'
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
to
eq
(
expect
(
json_response
).
to
eq
(
'name'
=>
'my_feature'
,
'name'
=>
'my_feature'
,
'state'
=>
'conditional'
,
'state'
=>
'conditional'
,
...
@@ -106,7 +106,7 @@ describe API::Features do
...
@@ -106,7 +106,7 @@ describe API::Features do
it
'creates an enabled feature for the given user when passed user=username'
do
it
'creates an enabled feature for the given user when passed user=username'
do
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
user:
user
.
username
}
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
user:
user
.
username
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
to
eq
(
expect
(
json_response
).
to
eq
(
'name'
=>
'my_feature'
,
'name'
=>
'my_feature'
,
'state'
=>
'conditional'
,
'state'
=>
'conditional'
,
...
@@ -119,7 +119,7 @@ describe API::Features do
...
@@ -119,7 +119,7 @@ describe API::Features do
it
'creates an enabled feature for the given user and feature group when passed user=username and feature_group=perf_team'
do
it
'creates an enabled feature for the given user and feature group when passed user=username and feature_group=perf_team'
do
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
user:
user
.
username
,
feature_group:
'perf_team'
}
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
user:
user
.
username
,
feature_group:
'perf_team'
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'name'
]).
to
eq
(
'my_feature'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'my_feature'
)
expect
(
json_response
[
'state'
]).
to
eq
(
'conditional'
)
expect
(
json_response
[
'state'
]).
to
eq
(
'conditional'
)
expect
(
json_response
[
'gates'
]).
to
contain_exactly
(
expect
(
json_response
[
'gates'
]).
to
contain_exactly
(
...
@@ -137,7 +137,7 @@ describe API::Features do
...
@@ -137,7 +137,7 @@ describe API::Features do
it
'sets the feature gate'
do
it
'sets the feature gate'
do
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
project:
project
.
full_path
}
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
project:
project
.
full_path
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
to
eq
(
expect
(
json_response
).
to
eq
(
'name'
=>
'my_feature'
,
'name'
=>
'my_feature'
,
'state'
=>
'conditional'
,
'state'
=>
'conditional'
,
...
@@ -152,7 +152,7 @@ describe API::Features do
...
@@ -152,7 +152,7 @@ describe API::Features do
it
'sets no new values'
do
it
'sets no new values'
do
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
project:
'mep/to/the/mep/mep'
}
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
project:
'mep/to/the/mep/mep'
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
to
eq
(
expect
(
json_response
).
to
eq
(
"name"
=>
"my_feature"
,
"name"
=>
"my_feature"
,
"state"
=>
"off"
,
"state"
=>
"off"
,
...
@@ -171,7 +171,7 @@ describe API::Features do
...
@@ -171,7 +171,7 @@ describe API::Features do
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
group:
group
.
full_path
}
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
group:
group
.
full_path
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
to
eq
(
expect
(
json_response
).
to
eq
(
'name'
=>
'my_feature'
,
'name'
=>
'my_feature'
,
'state'
=>
'conditional'
,
'state'
=>
'conditional'
,
...
@@ -186,7 +186,7 @@ describe API::Features do
...
@@ -186,7 +186,7 @@ describe API::Features do
it
'sets no new values and keeps the feature disabled'
do
it
'sets no new values and keeps the feature disabled'
do
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
group:
'not/a/group'
}
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
group:
'not/a/group'
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
to
eq
(
expect
(
json_response
).
to
eq
(
"name"
=>
"my_feature"
,
"name"
=>
"my_feature"
,
"state"
=>
"off"
,
"state"
=>
"off"
,
...
@@ -201,7 +201,7 @@ describe API::Features do
...
@@ -201,7 +201,7 @@ describe API::Features do
it
'creates a feature with the given percentage if passed an integer'
do
it
'creates a feature with the given percentage if passed an integer'
do
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'50'
}
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'50'
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
to
eq
(
expect
(
json_response
).
to
eq
(
'name'
=>
'my_feature'
,
'name'
=>
'my_feature'
,
'state'
=>
'conditional'
,
'state'
=>
'conditional'
,
...
@@ -223,7 +223,7 @@ describe API::Features do
...
@@ -223,7 +223,7 @@ describe API::Features do
it
'enables the feature'
do
it
'enables the feature'
do
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
}
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
to
eq
(
expect
(
json_response
).
to
eq
(
'name'
=>
'my_feature'
,
'name'
=>
'my_feature'
,
'state'
=>
'on'
,
'state'
=>
'on'
,
...
@@ -233,7 +233,7 @@ describe API::Features do
...
@@ -233,7 +233,7 @@ describe API::Features do
it
'enables the feature for the given Flipper group when passed feature_group=perf_team'
do
it
'enables the feature for the given Flipper group when passed feature_group=perf_team'
do
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
feature_group:
'perf_team'
}
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
feature_group:
'perf_team'
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
to
eq
(
expect
(
json_response
).
to
eq
(
'name'
=>
'my_feature'
,
'name'
=>
'my_feature'
,
'state'
=>
'conditional'
,
'state'
=>
'conditional'
,
...
@@ -246,7 +246,7 @@ describe API::Features do
...
@@ -246,7 +246,7 @@ describe API::Features do
it
'enables the feature for the given user when passed user=username'
do
it
'enables the feature for the given user when passed user=username'
do
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
user:
user
.
username
}
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
user:
user
.
username
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
to
eq
(
expect
(
json_response
).
to
eq
(
'name'
=>
'my_feature'
,
'name'
=>
'my_feature'
,
'state'
=>
'conditional'
,
'state'
=>
'conditional'
,
...
@@ -264,7 +264,7 @@ describe API::Features do
...
@@ -264,7 +264,7 @@ describe API::Features do
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'false'
}
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'false'
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
to
eq
(
expect
(
json_response
).
to
eq
(
'name'
=>
'my_feature'
,
'name'
=>
'my_feature'
,
'state'
=>
'off'
,
'state'
=>
'off'
,
...
@@ -277,7 +277,7 @@ describe API::Features do
...
@@ -277,7 +277,7 @@ describe API::Features do
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'false'
,
feature_group:
'perf_team'
}
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'false'
,
feature_group:
'perf_team'
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
to
eq
(
expect
(
json_response
).
to
eq
(
'name'
=>
'my_feature'
,
'name'
=>
'my_feature'
,
'state'
=>
'off'
,
'state'
=>
'off'
,
...
@@ -290,7 +290,7 @@ describe API::Features do
...
@@ -290,7 +290,7 @@ describe API::Features do
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'false'
,
user:
user
.
username
}
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'false'
,
user:
user
.
username
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
to
eq
(
expect
(
json_response
).
to
eq
(
'name'
=>
'my_feature'
,
'name'
=>
'my_feature'
,
'state'
=>
'off'
,
'state'
=>
'off'
,
...
@@ -306,7 +306,7 @@ describe API::Features do
...
@@ -306,7 +306,7 @@ describe API::Features do
it
'updates the percentage of time if passed an integer'
do
it
'updates the percentage of time if passed an integer'
do
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'30'
}
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'30'
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
to
eq
(
expect
(
json_response
).
to
eq
(
'name'
=>
'my_feature'
,
'name'
=>
'my_feature'
,
'state'
=>
'conditional'
,
'state'
=>
'conditional'
,
...
@@ -326,13 +326,13 @@ describe API::Features do
...
@@ -326,13 +326,13 @@ describe API::Features do
it
'returns a 401 for anonymous users'
do
it
'returns a 401 for anonymous users'
do
delete
api
(
"/features/
#{
feature_name
}
"
)
delete
api
(
"/features/
#{
feature_name
}
"
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
it
'returns a 403 for users'
do
it
'returns a 403 for users'
do
delete
api
(
"/features/
#{
feature_name
}
"
,
user
)
delete
api
(
"/features/
#{
feature_name
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -340,7 +340,7 @@ describe API::Features do
...
@@ -340,7 +340,7 @@ describe API::Features do
it
'returns 204 when the value is not set'
do
it
'returns 204 when the value is not set'
do
delete
api
(
"/features/
#{
feature_name
}
"
,
admin
)
delete
api
(
"/features/
#{
feature_name
}
"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
end
context
'when the gate value was set'
do
context
'when the gate value was set'
do
...
@@ -351,7 +351,7 @@ describe API::Features do
...
@@ -351,7 +351,7 @@ describe API::Features do
it
'deletes an enabled feature'
do
it
'deletes an enabled feature'
do
delete
api
(
"/features/
#{
feature_name
}
"
,
admin
)
delete
api
(
"/features/
#{
feature_name
}
"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
expect
(
Feature
.
get
(
feature_name
)).
not_to
be_enabled
expect
(
Feature
.
get
(
feature_name
)).
not_to
be_enabled
end
end
end
end
...
...
spec/requests/api/files_spec.rb
View file @
ad35e902
...
@@ -58,7 +58,7 @@ describe API::Files do
...
@@ -58,7 +58,7 @@ describe API::Files do
it
'returns file attributes in headers'
do
it
'returns file attributes in headers'
do
head
api
(
route
(
file_path
),
current_user
),
params:
params
head
api
(
route
(
file_path
),
current_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
.
headers
[
'X-Gitlab-File-Path'
]).
to
eq
(
CGI
.
unescape
(
file_path
))
expect
(
response
.
headers
[
'X-Gitlab-File-Path'
]).
to
eq
(
CGI
.
unescape
(
file_path
))
expect
(
response
.
headers
[
'X-Gitlab-File-Name'
]).
to
eq
(
'popen.rb'
)
expect
(
response
.
headers
[
'X-Gitlab-File-Name'
]).
to
eq
(
'popen.rb'
)
expect
(
response
.
headers
[
'X-Gitlab-Last-Commit-Id'
]).
to
eq
(
'570e7b2abdd848b95f2f578043fc23bd6f6fd24d'
)
expect
(
response
.
headers
[
'X-Gitlab-Last-Commit-Id'
]).
to
eq
(
'570e7b2abdd848b95f2f578043fc23bd6f6fd24d'
)
...
@@ -72,7 +72,7 @@ describe API::Files do
...
@@ -72,7 +72,7 @@ describe API::Files do
head
api
(
route
(
file_path
),
current_user
),
params:
params
head
api
(
route
(
file_path
),
current_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
.
headers
[
'X-Gitlab-File-Name'
]).
to
eq
(
'commit.js.coffee'
)
expect
(
response
.
headers
[
'X-Gitlab-File-Name'
]).
to
eq
(
'commit.js.coffee'
)
expect
(
response
.
headers
[
'X-Gitlab-Content-Sha256'
]).
to
eq
(
'08785f04375b47f81f46e68cc125d5ef368aa20576ddb53f91f4d83f1d04b929'
)
expect
(
response
.
headers
[
'X-Gitlab-Content-Sha256'
]).
to
eq
(
'08785f04375b47f81f46e68cc125d5ef368aa20576ddb53f91f4d83f1d04b929'
)
end
end
...
@@ -81,7 +81,7 @@ describe API::Files do
...
@@ -81,7 +81,7 @@ describe API::Files do
it
"responds with a 400 status"
do
it
"responds with a 400 status"
do
head
api
(
route
(
"any%2Ffile"
),
current_user
)
head
api
(
route
(
"any%2Ffile"
),
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
...
@@ -91,7 +91,7 @@ describe API::Files do
...
@@ -91,7 +91,7 @@ describe API::Files do
head
api
(
route
(
'app%2Fmodels%2Fapplication%2Erb'
),
current_user
),
params:
params
head
api
(
route
(
'app%2Fmodels%2Fapplication%2Erb'
),
current_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -101,7 +101,7 @@ describe API::Files do
...
@@ -101,7 +101,7 @@ describe API::Files do
it
"responds with a 403 status"
do
it
"responds with a 403 status"
do
head
api
(
route
(
file_path
),
current_user
),
params:
params
head
api
(
route
(
file_path
),
current_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -119,7 +119,7 @@ describe API::Files do
...
@@ -119,7 +119,7 @@ describe API::Files do
head
api
(
route
(
file_path
),
current_user
),
params:
params
head
api
(
route
(
file_path
),
current_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -148,7 +148,7 @@ describe API::Files do
...
@@ -148,7 +148,7 @@ describe API::Files do
it
'returns file attributes as json'
do
it
'returns file attributes as json'
do
get
api
(
route
(
file_path
),
current_user
),
params:
params
get
api
(
route
(
file_path
),
current_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'file_path'
]).
to
eq
(
CGI
.
unescape
(
file_path
))
expect
(
json_response
[
'file_path'
]).
to
eq
(
CGI
.
unescape
(
file_path
))
expect
(
json_response
[
'file_name'
]).
to
eq
(
'popen.rb'
)
expect
(
json_response
[
'file_name'
]).
to
eq
(
'popen.rb'
)
expect
(
json_response
[
'last_commit_id'
]).
to
eq
(
'570e7b2abdd848b95f2f578043fc23bd6f6fd24d'
)
expect
(
json_response
[
'last_commit_id'
]).
to
eq
(
'570e7b2abdd848b95f2f578043fc23bd6f6fd24d'
)
...
@@ -161,7 +161,7 @@ describe API::Files do
...
@@ -161,7 +161,7 @@ describe API::Files do
get
api
(
route
(
file_path
),
current_user
),
params:
params
get
api
(
route
(
file_path
),
current_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
.
content_type
).
to
eq
(
'application/json'
)
expect
(
response
.
content_type
).
to
eq
(
'application/json'
)
end
end
...
@@ -172,7 +172,7 @@ describe API::Files do
...
@@ -172,7 +172,7 @@ describe API::Files do
get
api
(
route
(
file_path
),
current_user
),
params:
params
get
api
(
route
(
file_path
),
current_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'file_name'
]).
to
eq
(
'commit.js.coffee'
)
expect
(
json_response
[
'file_name'
]).
to
eq
(
'commit.js.coffee'
)
expect
(
json_response
[
'content_sha256'
]).
to
eq
(
'08785f04375b47f81f46e68cc125d5ef368aa20576ddb53f91f4d83f1d04b929'
)
expect
(
json_response
[
'content_sha256'
]).
to
eq
(
'08785f04375b47f81f46e68cc125d5ef368aa20576ddb53f91f4d83f1d04b929'
)
expect
(
Base64
.
decode64
(
json_response
[
'content'
]).
lines
.
first
).
to
eq
(
"class Commit
\n
"
)
expect
(
Base64
.
decode64
(
json_response
[
'content'
]).
lines
.
first
).
to
eq
(
"class Commit
\n
"
)
...
@@ -184,7 +184,7 @@ describe API::Files do
...
@@ -184,7 +184,7 @@ describe API::Files do
get
api
(
url
,
current_user
),
params:
params
get
api
(
url
,
current_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
headers
[
Gitlab
::
Workhorse
::
DETECT_HEADER
]).
to
eq
"true"
expect
(
headers
[
Gitlab
::
Workhorse
::
DETECT_HEADER
]).
to
eq
"true"
end
end
...
@@ -193,7 +193,7 @@ describe API::Files do
...
@@ -193,7 +193,7 @@ describe API::Files do
get
api
(
url
,
current_user
),
params:
params
get
api
(
url
,
current_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'sets inline content disposition by default'
do
it
'sets inline content disposition by default'
do
...
@@ -294,7 +294,7 @@ describe API::Files do
...
@@ -294,7 +294,7 @@ describe API::Files do
it
'returns file attributes in headers'
do
it
'returns file attributes in headers'
do
head
api
(
route
(
file_path
)
+
'/blame'
,
current_user
),
params:
params
head
api
(
route
(
file_path
)
+
'/blame'
,
current_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
.
headers
[
'X-Gitlab-File-Path'
]).
to
eq
(
CGI
.
unescape
(
file_path
))
expect
(
response
.
headers
[
'X-Gitlab-File-Path'
]).
to
eq
(
CGI
.
unescape
(
file_path
))
expect
(
response
.
headers
[
'X-Gitlab-File-Name'
]).
to
eq
(
'popen.rb'
)
expect
(
response
.
headers
[
'X-Gitlab-File-Name'
]).
to
eq
(
'popen.rb'
)
expect
(
response
.
headers
[
'X-Gitlab-Last-Commit-Id'
]).
to
eq
(
'570e7b2abdd848b95f2f578043fc23bd6f6fd24d'
)
expect
(
response
.
headers
[
'X-Gitlab-Last-Commit-Id'
]).
to
eq
(
'570e7b2abdd848b95f2f578043fc23bd6f6fd24d'
)
...
@@ -305,7 +305,7 @@ describe API::Files do
...
@@ -305,7 +305,7 @@ describe API::Files do
it
'returns blame file attributes as json'
do
it
'returns blame file attributes as json'
do
get
api
(
route
(
file_path
)
+
'/blame'
,
current_user
),
params:
params
get
api
(
route
(
file_path
)
+
'/blame'
,
current_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
.
map
{
|
x
|
x
[
'lines'
].
size
}).
to
eq
(
expected_blame_range_sizes
)
expect
(
json_response
.
map
{
|
x
|
x
[
'lines'
].
size
}).
to
eq
(
expected_blame_range_sizes
)
expect
(
json_response
.
map
{
|
x
|
x
[
'commit'
][
'id'
]
}).
to
eq
(
expected_blame_range_commit_ids
)
expect
(
json_response
.
map
{
|
x
|
x
[
'commit'
][
'id'
]
}).
to
eq
(
expected_blame_range_commit_ids
)
range
=
json_response
[
0
]
range
=
json_response
[
0
]
...
@@ -329,7 +329,7 @@ describe API::Files do
...
@@ -329,7 +329,7 @@ describe API::Files do
get
api
(
url
,
current_user
),
params:
params
get
api
(
url
,
current_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'returns file by commit sha'
do
it
'returns file by commit sha'
do
...
@@ -339,7 +339,7 @@ describe API::Files do
...
@@ -339,7 +339,7 @@ describe API::Files do
get
api
(
route
(
file_path
)
+
'/blame'
,
current_user
),
params:
params
get
api
(
route
(
file_path
)
+
'/blame'
,
current_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
context
'when mandatory params are not given'
do
context
'when mandatory params are not given'
do
...
@@ -411,7 +411,7 @@ describe API::Files do
...
@@ -411,7 +411,7 @@ describe API::Files do
get
api
(
route
(
file_path
)
+
'/blame'
,
personal_access_token:
token
),
params:
params
get
api
(
route
(
file_path
)
+
'/blame'
,
personal_access_token:
token
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
end
end
...
@@ -424,7 +424,7 @@ describe API::Files do
...
@@ -424,7 +424,7 @@ describe API::Files do
get
api
(
url
,
current_user
),
params:
params
get
api
(
url
,
current_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'returns raw file info for files with dots'
do
it
'returns raw file info for files with dots'
do
...
@@ -433,7 +433,7 @@ describe API::Files do
...
@@ -433,7 +433,7 @@ describe API::Files do
get
api
(
url
,
current_user
),
params:
params
get
api
(
url
,
current_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'returns file by commit sha'
do
it
'returns file by commit sha'
do
...
@@ -444,7 +444,7 @@ describe API::Files do
...
@@ -444,7 +444,7 @@ describe API::Files do
get
api
(
route
(
file_path
)
+
"/raw"
,
current_user
),
params:
params
get
api
(
route
(
file_path
)
+
"/raw"
,
current_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'sets no-cache headers'
do
it
'sets no-cache headers'
do
...
@@ -520,7 +520,7 @@ describe API::Files do
...
@@ -520,7 +520,7 @@ describe API::Files do
get
api
(
route
(
file_path
)
+
"/raw"
,
personal_access_token:
token
),
params:
params
get
api
(
route
(
file_path
)
+
"/raw"
,
personal_access_token:
token
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
end
end
...
@@ -538,7 +538,7 @@ describe API::Files do
...
@@ -538,7 +538,7 @@ describe API::Files do
it
"creates a new file in project repo"
do
it
"creates a new file in project repo"
do
post
api
(
route
(
file_path
),
user
),
params:
params
post
api
(
route
(
file_path
),
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
"file_path"
]).
to
eq
(
CGI
.
unescape
(
file_path
))
expect
(
json_response
[
"file_path"
]).
to
eq
(
CGI
.
unescape
(
file_path
))
last_commit
=
project
.
repository
.
commit
.
raw
last_commit
=
project
.
repository
.
commit
.
raw
expect
(
last_commit
.
author_email
).
to
eq
(
user
.
email
)
expect
(
last_commit
.
author_email
).
to
eq
(
user
.
email
)
...
@@ -548,7 +548,7 @@ describe API::Files do
...
@@ -548,7 +548,7 @@ describe API::Files do
it
"returns a 400 bad request if no mandatory params given"
do
it
"returns a 400 bad request if no mandatory params given"
do
post
api
(
route
(
"any%2Etxt"
),
user
)
post
api
(
route
(
"any%2Etxt"
),
user
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
'returns a 400 bad request if the commit message is empty'
do
it
'returns a 400 bad request if the commit message is empty'
do
...
@@ -556,7 +556,7 @@ describe API::Files do
...
@@ -556,7 +556,7 @@ describe API::Files do
post
api
(
route
(
file_path
),
user
),
params:
params
post
api
(
route
(
file_path
),
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
"returns a 400 if editor fails to create file"
do
it
"returns a 400 if editor fails to create file"
do
...
@@ -566,7 +566,7 @@ describe API::Files do
...
@@ -566,7 +566,7 @@ describe API::Files do
post
api
(
route
(
"any%2Etxt"
),
user
),
params:
params
post
api
(
route
(
"any%2Etxt"
),
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
context
'with PATs'
do
context
'with PATs'
do
...
@@ -575,7 +575,7 @@ describe API::Files do
...
@@ -575,7 +575,7 @@ describe API::Files do
post
api
(
route
(
file_path
),
personal_access_token:
token
),
params:
params
post
api
(
route
(
file_path
),
personal_access_token:
token
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
it
'returns 201 with `api` scope'
do
it
'returns 201 with `api` scope'
do
...
@@ -583,7 +583,7 @@ describe API::Files do
...
@@ -583,7 +583,7 @@ describe API::Files do
post
api
(
route
(
file_path
),
personal_access_token:
token
),
params:
params
post
api
(
route
(
file_path
),
personal_access_token:
token
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
end
end
end
end
...
@@ -593,7 +593,7 @@ describe API::Files do
...
@@ -593,7 +593,7 @@ describe API::Files do
post
api
(
route
(
"new_file_with_author%2Etxt"
),
user
),
params:
params
post
api
(
route
(
"new_file_with_author%2Etxt"
),
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
response
.
content_type
).
to
eq
(
'application/json'
)
expect
(
response
.
content_type
).
to
eq
(
'application/json'
)
last_commit
=
project
.
repository
.
commit
.
raw
last_commit
=
project
.
repository
.
commit
.
raw
expect
(
last_commit
.
author_email
).
to
eq
(
author_email
)
expect
(
last_commit
.
author_email
).
to
eq
(
author_email
)
...
@@ -607,7 +607,7 @@ describe API::Files do
...
@@ -607,7 +607,7 @@ describe API::Files do
it
"creates a new file in project repo"
do
it
"creates a new file in project repo"
do
post
api
(
route
(
"newfile%2Erb"
),
user
),
params:
params
post
api
(
route
(
"newfile%2Erb"
),
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'file_path'
]).
to
eq
(
'newfile.rb'
)
expect
(
json_response
[
'file_path'
]).
to
eq
(
'newfile.rb'
)
last_commit
=
project
.
repository
.
commit
.
raw
last_commit
=
project
.
repository
.
commit
.
raw
expect
(
last_commit
.
author_email
).
to
eq
(
user
.
email
)
expect
(
last_commit
.
author_email
).
to
eq
(
user
.
email
)
...
@@ -628,7 +628,7 @@ describe API::Files do
...
@@ -628,7 +628,7 @@ describe API::Files do
it
"updates existing file in project repo"
do
it
"updates existing file in project repo"
do
put
api
(
route
(
file_path
),
user
),
params:
params
put
api
(
route
(
file_path
),
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'file_path'
]).
to
eq
(
CGI
.
unescape
(
file_path
))
expect
(
json_response
[
'file_path'
]).
to
eq
(
CGI
.
unescape
(
file_path
))
last_commit
=
project
.
repository
.
commit
.
raw
last_commit
=
project
.
repository
.
commit
.
raw
expect
(
last_commit
.
author_email
).
to
eq
(
user
.
email
)
expect
(
last_commit
.
author_email
).
to
eq
(
user
.
email
)
...
@@ -640,7 +640,7 @@ describe API::Files do
...
@@ -640,7 +640,7 @@ describe API::Files do
put
api
(
route
(
file_path
),
user
),
params:
params
put
api
(
route
(
file_path
),
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
"returns a 400 bad request if update existing file with stale last commit id"
do
it
"returns a 400 bad request if update existing file with stale last commit id"
do
...
@@ -648,7 +648,7 @@ describe API::Files do
...
@@ -648,7 +648,7 @@ describe API::Files do
put
api
(
route
(
file_path
),
user
),
params:
params_with_stale_id
put
api
(
route
(
file_path
),
user
),
params:
params_with_stale_id
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
]).
to
eq
(
_
(
'You are attempting to update a file that has changed since you started editing it.'
))
expect
(
json_response
[
'message'
]).
to
eq
(
_
(
'You are attempting to update a file that has changed since you started editing it.'
))
end
end
...
@@ -659,13 +659,13 @@ describe API::Files do
...
@@ -659,13 +659,13 @@ describe API::Files do
put
api
(
route
(
file_path
),
user
),
params:
params_with_correct_id
put
api
(
route
(
file_path
),
user
),
params:
params_with_correct_id
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
"returns a 400 bad request if no params given"
do
it
"returns a 400 bad request if no params given"
do
put
api
(
route
(
file_path
),
user
)
put
api
(
route
(
file_path
),
user
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
context
"when specifying an author"
do
context
"when specifying an author"
do
...
@@ -674,7 +674,7 @@ describe API::Files do
...
@@ -674,7 +674,7 @@ describe API::Files do
put
api
(
route
(
file_path
),
user
),
params:
params
put
api
(
route
(
file_path
),
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
last_commit
=
project
.
repository
.
commit
.
raw
last_commit
=
project
.
repository
.
commit
.
raw
expect
(
last_commit
.
author_email
).
to
eq
(
author_email
)
expect
(
last_commit
.
author_email
).
to
eq
(
author_email
)
expect
(
last_commit
.
author_name
).
to
eq
(
author_name
)
expect
(
last_commit
.
author_name
).
to
eq
(
author_name
)
...
@@ -693,13 +693,13 @@ describe API::Files do
...
@@ -693,13 +693,13 @@ describe API::Files do
it
"deletes existing file in project repo"
do
it
"deletes existing file in project repo"
do
delete
api
(
route
(
file_path
),
user
),
params:
params
delete
api
(
route
(
file_path
),
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
end
it
"returns a 400 bad request if no params given"
do
it
"returns a 400 bad request if no params given"
do
delete
api
(
route
(
file_path
),
user
)
delete
api
(
route
(
file_path
),
user
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
'returns a 400 bad request if the commit message is empty'
do
it
'returns a 400 bad request if the commit message is empty'
do
...
@@ -707,7 +707,7 @@ describe API::Files do
...
@@ -707,7 +707,7 @@ describe API::Files do
delete
api
(
route
(
file_path
),
user
),
params:
params
delete
api
(
route
(
file_path
),
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
"returns a 400 if fails to delete file"
do
it
"returns a 400 if fails to delete file"
do
...
@@ -717,7 +717,7 @@ describe API::Files do
...
@@ -717,7 +717,7 @@ describe API::Files do
delete
api
(
route
(
file_path
),
user
),
params:
params
delete
api
(
route
(
file_path
),
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
context
"when specifying an author"
do
context
"when specifying an author"
do
...
@@ -726,7 +726,7 @@ describe API::Files do
...
@@ -726,7 +726,7 @@ describe API::Files do
delete
api
(
route
(
file_path
),
user
),
params:
params
delete
api
(
route
(
file_path
),
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
end
end
end
end
end
...
@@ -754,7 +754,7 @@ describe API::Files do
...
@@ -754,7 +754,7 @@ describe API::Files do
it
"remains unchanged"
do
it
"remains unchanged"
do
get
api
(
route
(
file_path
),
user
),
params:
get_params
get
api
(
route
(
file_path
),
user
),
params:
get_params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'file_path'
]).
to
eq
(
CGI
.
unescape
(
file_path
))
expect
(
json_response
[
'file_path'
]).
to
eq
(
CGI
.
unescape
(
file_path
))
expect
(
json_response
[
'file_name'
]).
to
eq
(
CGI
.
unescape
(
file_path
))
expect
(
json_response
[
'file_name'
]).
to
eq
(
CGI
.
unescape
(
file_path
))
expect
(
json_response
[
'content'
]).
to
eq
(
put_params
[
:content
])
expect
(
json_response
[
'content'
]).
to
eq
(
put_params
[
:content
])
...
...
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