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
765fc43b
Commit
765fc43b
authored
Feb 25, 2020
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add http status cop to api specs a-o
248 files inspected, 326 offenses detected, 326 offenses corrected
parent
885e4d44
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
328 additions
and
328 deletions
+328
-328
.rubocop.yml
.rubocop.yml
+2
-2
ee/spec/requests/api/managed_licenses_spec.rb
ee/spec/requests/api/managed_licenses_spec.rb
+26
-26
ee/spec/requests/api/members_spec.rb
ee/spec/requests/api/members_spec.rb
+9
-9
ee/spec/requests/api/merge_request_approval_rules_spec.rb
ee/spec/requests/api/merge_request_approval_rules_spec.rb
+8
-8
ee/spec/requests/api/merge_request_approvals_spec.rb
ee/spec/requests/api/merge_request_approvals_spec.rb
+25
-25
ee/spec/requests/api/merge_requests_spec.rb
ee/spec/requests/api/merge_requests_spec.rb
+11
-11
ee/spec/requests/api/namespaces_spec.rb
ee/spec/requests/api/namespaces_spec.rb
+21
-21
ee/spec/requests/api/notes_spec.rb
ee/spec/requests/api/notes_spec.rb
+2
-2
ee/spec/requests/api/npm_packages_spec.rb
ee/spec/requests/api/npm_packages_spec.rb
+18
-18
spec/requests/api/markdown_spec.rb
spec/requests/api/markdown_spec.rb
+7
-7
spec/requests/api/members_spec.rb
spec/requests/api/members_spec.rb
+30
-30
spec/requests/api/merge_request_diffs_spec.rb
spec/requests/api/merge_request_diffs_spec.rb
+5
-5
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+133
-133
spec/requests/api/namespaces_spec.rb
spec/requests/api/namespaces_spec.rb
+11
-11
spec/requests/api/notes_spec.rb
spec/requests/api/notes_spec.rb
+9
-9
spec/requests/api/notification_settings_spec.rb
spec/requests/api/notification_settings_spec.rb
+8
-8
spec/requests/api/oauth_tokens_spec.rb
spec/requests/api/oauth_tokens_spec.rb
+3
-3
No files found.
.rubocop.yml
View file @
765fc43b
...
@@ -349,8 +349,8 @@ RSpec/HaveGitlabHttpStatus:
...
@@ -349,8 +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-
l
]*.rb'
-
'
spec/requests/api/[a-
o
]*.rb'
-
'
ee/spec/requests/api/[a-
l
]*.rb'
-
'
ee/spec/requests/api/[a-
o
]*.rb'
Style/MultilineWhenThen
:
Style/MultilineWhenThen
:
Enabled
:
false
Enabled
:
false
...
...
ee/spec/requests/api/managed_licenses_spec.rb
View file @
765fc43b
...
@@ -25,7 +25,7 @@ describe API::ManagedLicenses do
...
@@ -25,7 +25,7 @@ describe API::ManagedLicenses do
it
'returns a forbidden status'
do
it
'returns a forbidden status'
do
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses"
,
dev_user
)
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses"
,
dev_user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -33,7 +33,7 @@ describe API::ManagedLicenses do
...
@@ -33,7 +33,7 @@ describe API::ManagedLicenses do
it
'returns project managed licenses'
do
it
'returns project managed licenses'
do
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses"
,
dev_user
)
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses"
,
dev_user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'managed_licenses'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'managed_licenses'
,
dir:
'ee'
)
expect
(
json_response
).
to
be_a
(
Array
)
expect
(
json_response
).
to
be_a
(
Array
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
software_license_policy
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
software_license_policy
.
id
)
...
@@ -46,7 +46,7 @@ describe API::ManagedLicenses do
...
@@ -46,7 +46,7 @@ describe API::ManagedLicenses do
it
'returns project managed licenses to users with read permissions'
do
it
'returns project managed licenses to users with read permissions'
do
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses"
,
reporter_user
)
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses"
,
reporter_user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'managed_licenses'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'managed_licenses'
,
dir:
'ee'
)
expect
(
json_response
).
to
be_a
(
Array
)
expect
(
json_response
).
to
be_a
(
Array
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
software_license_policy
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
software_license_policy
.
id
)
...
@@ -59,14 +59,14 @@ describe API::ManagedLicenses do
...
@@ -59,14 +59,14 @@ describe API::ManagedLicenses do
it
'returns project managed licenses for public project'
do
it
'returns project managed licenses for public project'
do
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses"
)
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses"
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'managed_licenses'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'managed_licenses'
,
dir:
'ee'
)
end
end
it
'responses with 404 Not Found for not existing project'
do
it
'responses with 404 Not Found for not existing project'
do
get
api
(
"/projects/0/managed_licenses"
)
get
api
(
"/projects/0/managed_licenses"
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
context
'when project is private'
do
context
'when project is private'
do
...
@@ -77,7 +77,7 @@ describe API::ManagedLicenses do
...
@@ -77,7 +77,7 @@ describe API::ManagedLicenses do
it
'responses with 404 Not Found'
do
it
'responses with 404 Not Found'
do
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses"
)
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses"
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
@@ -88,7 +88,7 @@ describe API::ManagedLicenses do
...
@@ -88,7 +88,7 @@ describe API::ManagedLicenses do
it
'returns project managed license details'
do
it
'returns project managed license details'
do
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
,
dev_user
)
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
,
dev_user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'software_license_policy'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'software_license_policy'
,
dir:
'ee'
)
expect
(
json_response
[
'id'
]).
to
eq
(
software_license_policy
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
software_license_policy
.
id
)
expect
(
json_response
[
'name'
]).
to
eq
(
software_license_policy
.
name
)
expect
(
json_response
[
'name'
]).
to
eq
(
software_license_policy
.
name
)
...
@@ -99,7 +99,7 @@ describe API::ManagedLicenses do
...
@@ -99,7 +99,7 @@ describe API::ManagedLicenses do
escaped_name
=
CGI
.
escape
(
software_license_policy
.
name
)
escaped_name
=
CGI
.
escape
(
software_license_policy
.
name
)
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
escaped_name
}
"
,
dev_user
)
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
escaped_name
}
"
,
dev_user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'software_license_policy'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'software_license_policy'
,
dir:
'ee'
)
expect
(
json_response
[
'id'
]).
to
eq
(
software_license_policy
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
software_license_policy
.
id
)
expect
(
json_response
[
'name'
]).
to
eq
(
software_license_policy
.
name
)
expect
(
json_response
[
'name'
]).
to
eq
(
software_license_policy
.
name
)
...
@@ -109,7 +109,7 @@ describe API::ManagedLicenses do
...
@@ -109,7 +109,7 @@ describe API::ManagedLicenses do
it
'responds with 404 Not Found if requesting non-existing managed license'
do
it
'responds with 404 Not Found if requesting non-existing managed license'
do
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/1234512345"
,
dev_user
)
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/1234512345"
,
dev_user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -117,7 +117,7 @@ describe API::ManagedLicenses do
...
@@ -117,7 +117,7 @@ describe API::ManagedLicenses do
it
'returns project managed license details'
do
it
'returns project managed license details'
do
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
,
reporter_user
)
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
,
reporter_user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'software_license_policy'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'software_license_policy'
,
dir:
'ee'
)
expect
(
json_response
[
'id'
]).
to
eq
(
software_license_policy
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
software_license_policy
.
id
)
expect
(
json_response
[
'name'
]).
to
eq
(
software_license_policy
.
name
)
expect
(
json_response
[
'name'
]).
to
eq
(
software_license_policy
.
name
)
...
@@ -129,7 +129,7 @@ describe API::ManagedLicenses do
...
@@ -129,7 +129,7 @@ describe API::ManagedLicenses do
it
'does not return project managed license details'
do
it
'does not return project managed license details'
do
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
)
get
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
end
end
...
@@ -145,7 +145,7 @@ describe API::ManagedLicenses do
...
@@ -145,7 +145,7 @@ describe API::ManagedLicenses do
}
}
end
.
to
change
{
project
.
software_license_policies
.
count
}.
by
(
1
)
end
.
to
change
{
project
.
software_license_policies
.
count
}.
by
(
1
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
response
).
to
match_response_schema
(
'software_license_policy'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'software_license_policy'
,
dir:
'ee'
)
expect
(
json_response
).
to
have_key
(
'id'
)
expect
(
json_response
).
to
have_key
(
'id'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'NEW_LICENSE_NAME'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'NEW_LICENSE_NAME'
)
...
@@ -161,7 +161,7 @@ describe API::ManagedLicenses do
...
@@ -161,7 +161,7 @@ describe API::ManagedLicenses do
}
}
end
.
not_to
change
{
project
.
software_license_policies
.
count
}
end
.
not_to
change
{
project
.
software_license_policies
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
...
@@ -173,7 +173,7 @@ describe API::ManagedLicenses do
...
@@ -173,7 +173,7 @@ describe API::ManagedLicenses do
approval_status:
'approved'
approval_status:
'approved'
}
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -185,7 +185,7 @@ describe API::ManagedLicenses do
...
@@ -185,7 +185,7 @@ describe API::ManagedLicenses do
approval_status:
'approved'
approval_status:
'approved'
}
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -197,7 +197,7 @@ describe API::ManagedLicenses do
...
@@ -197,7 +197,7 @@ describe API::ManagedLicenses do
approval_status:
'approved'
approval_status:
'approved'
}
}
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
end
end
...
@@ -214,7 +214,7 @@ describe API::ManagedLicenses do
...
@@ -214,7 +214,7 @@ describe API::ManagedLicenses do
updated_software_license_policy
=
project
.
software_license_policies
.
reload
.
first
updated_software_license_policy
=
project
.
software_license_policies
.
reload
.
first
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'software_license_policy'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'software_license_policy'
,
dir:
'ee'
)
# Check that response is equal to the updated object
# Check that response is equal to the updated object
...
@@ -234,7 +234,7 @@ describe API::ManagedLicenses do
...
@@ -234,7 +234,7 @@ describe API::ManagedLicenses do
it
'responds with 404 Not Found if requesting non-existing managed license'
do
it
'responds with 404 Not Found if requesting non-existing managed license'
do
patch
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/1234512345"
,
maintainer_user
)
patch
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/1234512345"
,
maintainer_user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -242,7 +242,7 @@ describe API::ManagedLicenses do
...
@@ -242,7 +242,7 @@ describe API::ManagedLicenses do
it
'does not update managed license'
do
it
'does not update managed license'
do
patch
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
,
dev_user
)
patch
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
,
dev_user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -250,7 +250,7 @@ describe API::ManagedLicenses do
...
@@ -250,7 +250,7 @@ describe API::ManagedLicenses do
it
'does not update managed license'
do
it
'does not update managed license'
do
patch
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
,
reporter_user
)
patch
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
,
reporter_user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -258,7 +258,7 @@ describe API::ManagedLicenses do
...
@@ -258,7 +258,7 @@ describe API::ManagedLicenses do
it
'does not update managed license'
do
it
'does not update managed license'
do
patch
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
)
patch
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
end
end
...
@@ -269,7 +269,7 @@ describe API::ManagedLicenses do
...
@@ -269,7 +269,7 @@ describe API::ManagedLicenses do
expect
do
expect
do
delete
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
,
maintainer_user
)
delete
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
,
maintainer_user
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
.
to
change
{
project
.
software_license_policies
.
count
}.
by
(
-
1
)
end
.
to
change
{
project
.
software_license_policies
.
count
}.
by
(
-
1
)
end
end
...
@@ -277,7 +277,7 @@ describe API::ManagedLicenses do
...
@@ -277,7 +277,7 @@ describe API::ManagedLicenses do
expect
do
expect
do
delete
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/1234512345"
,
maintainer_user
)
delete
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/1234512345"
,
maintainer_user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
.
not_to
change
{
project
.
software_license_policies
.
count
}
end
.
not_to
change
{
project
.
software_license_policies
.
count
}
end
end
end
end
...
@@ -287,7 +287,7 @@ describe API::ManagedLicenses do
...
@@ -287,7 +287,7 @@ describe API::ManagedLicenses do
expect
do
expect
do
delete
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
,
dev_user
)
delete
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
,
dev_user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
.
not_to
change
{
project
.
software_license_policies
.
count
}
end
.
not_to
change
{
project
.
software_license_policies
.
count
}
end
end
end
end
...
@@ -297,7 +297,7 @@ describe API::ManagedLicenses do
...
@@ -297,7 +297,7 @@ describe API::ManagedLicenses do
expect
do
expect
do
delete
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
,
reporter_user
)
delete
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
,
reporter_user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
.
not_to
change
{
project
.
software_license_policies
.
count
}
end
.
not_to
change
{
project
.
software_license_policies
.
count
}
end
end
end
end
...
@@ -307,7 +307,7 @@ describe API::ManagedLicenses do
...
@@ -307,7 +307,7 @@ describe API::ManagedLicenses do
expect
do
expect
do
delete
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
)
delete
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
.
not_to
change
{
project
.
software_license_policies
.
count
}
end
.
not_to
change
{
project
.
software_license_policies
.
count
}
end
end
end
end
...
...
ee/spec/requests/api/members_spec.rb
View file @
765fc43b
...
@@ -32,7 +32,7 @@ describe API::Members do
...
@@ -32,7 +32,7 @@ describe API::Members do
it
'matches json schema'
do
it
'matches json schema'
do
get
api
(
"/groups/
#{
group
.
to_param
}
/members"
,
owner
)
get
api
(
"/groups/
#{
group
.
to_param
}
/members"
,
owner
)
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/members'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/members'
)
end
end
...
@@ -50,7 +50,7 @@ describe API::Members do
...
@@ -50,7 +50,7 @@ describe API::Members do
it
'returns a list of users with group SAML identities info'
do
it
'returns a list of users with group SAML identities info'
do
get
api
(
"/groups/
#{
group
.
to_param
}
/members"
,
owner
)
get
api
(
"/groups/
#{
group
.
to_param
}
/members"
,
owner
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
.
size
).
to
eq
(
2
)
expect
(
json_response
.
size
).
to
eq
(
2
)
expect
(
json_response
.
first
[
'group_saml_identity'
]).
to
match
(
kind_of
(
Hash
))
expect
(
json_response
.
first
[
'group_saml_identity'
]).
to
match
(
kind_of
(
Hash
))
end
end
...
@@ -58,7 +58,7 @@ describe API::Members do
...
@@ -58,7 +58,7 @@ describe API::Members do
it
'allows to filter by linked identity presence'
do
it
'allows to filter by linked identity presence'
do
get
api
(
"/groups/
#{
group
.
to_param
}
/members?with_saml_identity=true"
,
owner
)
get
api
(
"/groups/
#{
group
.
to_param
}
/members?with_saml_identity=true"
,
owner
)
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
)
expect
(
json_response
.
any?
{
|
member
|
member
[
'id'
]
==
maintainer
.
id
}).
to
be_falsey
expect
(
json_response
.
any?
{
|
member
|
member
[
'id'
]
==
maintainer
.
id
}).
to
be_falsey
end
end
...
@@ -68,14 +68,14 @@ describe API::Members do
...
@@ -68,14 +68,14 @@ describe API::Members do
it
'returns a list of users without group SAML identities info'
do
it
'returns a list of users without group SAML identities info'
do
get
api
(
"/groups/
#{
group
.
to_param
}
/members"
,
maintainer
)
get
api
(
"/groups/
#{
group
.
to_param
}
/members"
,
maintainer
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
.
map
(
&
:keys
).
flatten
).
not_to
include
(
'group_saml_identity'
)
expect
(
json_response
.
map
(
&
:keys
).
flatten
).
not_to
include
(
'group_saml_identity'
)
end
end
it
'ignores filter by linked identity presence'
do
it
'ignores filter by linked identity presence'
do
get
api
(
"/groups/
#{
group
.
to_param
}
/members?with_saml_identity=true"
,
maintainer
)
get
api
(
"/groups/
#{
group
.
to_param
}
/members?with_saml_identity=true"
,
maintainer
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
.
size
).
to
eq
(
2
)
expect
(
json_response
.
size
).
to
eq
(
2
)
expect
(
json_response
.
any?
{
|
member
|
member
[
'id'
]
==
maintainer
.
id
}).
to
be_truthy
expect
(
json_response
.
any?
{
|
member
|
member
[
'id'
]
==
maintainer
.
id
}).
to
be_truthy
end
end
...
@@ -87,7 +87,7 @@ describe API::Members do
...
@@ -87,7 +87,7 @@ describe API::Members do
it
'returns a list of users that does not contain the is_using_seat attribute'
do
it
'returns a list of users that does not contain the is_using_seat attribute'
do
get
api
(
api_url
,
owner
)
get
api
(
api_url
,
owner
)
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
)
expect
(
json_response
.
first
.
keys
).
not_to
include
(
'is_using_seat'
)
expect
(
json_response
.
first
.
keys
).
not_to
include
(
'is_using_seat'
)
end
end
...
@@ -97,7 +97,7 @@ describe API::Members do
...
@@ -97,7 +97,7 @@ describe API::Members do
it
'returns a list of users that contains the is_using_seat attribute'
do
it
'returns a list of users that contains the is_using_seat attribute'
do
get
api
(
"/groups/
#{
group
.
to_param
}
/members?show_seat_info=true"
,
owner
)
get
api
(
"/groups/
#{
group
.
to_param
}
/members?show_seat_info=true"
,
owner
)
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
)
expect
(
json_response
.
first
[
'is_using_seat'
]).
to
be_truthy
expect
(
json_response
.
first
[
'is_using_seat'
]).
to
be_truthy
end
end
...
@@ -128,7 +128,7 @@ describe API::Members do
...
@@ -128,7 +128,7 @@ describe API::Members do
expect
do
expect
do
post
api
(
url
,
owner
),
params:
params
post
api
(
url
,
owner
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
end
.
to
change
{
AuditEvent
.
count
}.
by
(
1
)
end
.
to
change
{
AuditEvent
.
count
}.
by
(
1
)
end
end
...
@@ -138,7 +138,7 @@ describe API::Members do
...
@@ -138,7 +138,7 @@ describe API::Members do
expect
do
expect
do
post
api
(
url
,
owner
),
params:
params
post
api
(
url
,
owner
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
.
not_to
change
{
AuditEvent
.
count
}
end
.
not_to
change
{
AuditEvent
.
count
}
end
end
end
end
...
...
ee/spec/requests/api/merge_request_approval_rules_spec.rb
View file @
765fc43b
...
@@ -17,7 +17,7 @@ describe API::MergeRequestApprovalRules do
...
@@ -17,7 +17,7 @@ describe API::MergeRequestApprovalRules do
end
end
it
'responds with 403'
do
it
'responds with 403'
do
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -32,7 +32,7 @@ describe API::MergeRequestApprovalRules do
...
@@ -32,7 +32,7 @@ describe API::MergeRequestApprovalRules do
let
(
:current_user
)
{
other_user
}
let
(
:current_user
)
{
other_user
}
it
'responds with 403'
do
it
'responds with 403'
do
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -43,7 +43,7 @@ describe API::MergeRequestApprovalRules do
...
@@ -43,7 +43,7 @@ describe API::MergeRequestApprovalRules do
let
(
:approval_rule
)
{
create
(
:code_owner_rule
,
merge_request:
merge_request
)
}
let
(
:approval_rule
)
{
create
(
:code_owner_rule
,
merge_request:
merge_request
)
}
it
'responds with 403'
do
it
'responds with 403'
do
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -60,7 +60,7 @@ describe API::MergeRequestApprovalRules do
...
@@ -60,7 +60,7 @@ describe API::MergeRequestApprovalRules do
end
end
it
'responds with 403'
do
it
'responds with 403'
do
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -89,7 +89,7 @@ describe API::MergeRequestApprovalRules do
...
@@ -89,7 +89,7 @@ describe API::MergeRequestApprovalRules do
end
end
it
'matches the response schema'
do
it
'matches the response schema'
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/merge_request_approval_rules'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/merge_request_approval_rules'
,
dir:
'ee'
)
rules
=
json_response
rules
=
json_response
...
@@ -172,7 +172,7 @@ describe API::MergeRequestApprovalRules do
...
@@ -172,7 +172,7 @@ describe API::MergeRequestApprovalRules do
end
end
it
'matches the response schema'
do
it
'matches the response schema'
do
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/merge_request_approval_rule'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/merge_request_approval_rule'
,
dir:
'ee'
)
rule
=
json_response
rule
=
json_response
...
@@ -286,7 +286,7 @@ describe API::MergeRequestApprovalRules do
...
@@ -286,7 +286,7 @@ describe API::MergeRequestApprovalRules do
it_behaves_like
'a protected API endpoint that only allows action on regular merge request approval rule'
it_behaves_like
'a protected API endpoint that only allows action on regular merge request approval rule'
it
'matches the response schema'
do
it
'matches the response schema'
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/merge_request_approval_rule'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/merge_request_approval_rule'
,
dir:
'ee'
)
rule
=
json_response
rule
=
json_response
...
@@ -363,7 +363,7 @@ describe API::MergeRequestApprovalRules do
...
@@ -363,7 +363,7 @@ describe API::MergeRequestApprovalRules do
it_behaves_like
'a protected API endpoint that only allows action on regular merge request approval rule'
it_behaves_like
'a protected API endpoint that only allows action on regular merge request approval rule'
it
'responds with 204'
do
it
'responds with 204'
do
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
end
end
end
end
end
...
...
ee/spec/requests/api/merge_request_approvals_spec.rb
View file @
765fc43b
...
@@ -66,7 +66,7 @@ describe API::MergeRequestApprovals do
...
@@ -66,7 +66,7 @@ describe API::MergeRequestApprovals do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/approvals"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/approvals"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'approvals_required'
]).
to
eq
2
expect
(
json_response
[
'approvals_required'
]).
to
eq
2
expect
(
json_response
[
'approvals_left'
]).
to
eq
1
expect
(
json_response
[
'approvals_left'
]).
to
eq
1
expect
(
json_response
[
'approval_rules_left'
]).
to
be_empty
expect
(
json_response
[
'approval_rules_left'
]).
to
be_empty
...
@@ -86,7 +86,7 @@ describe API::MergeRequestApprovals do
...
@@ -86,7 +86,7 @@ describe API::MergeRequestApprovals do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/approvals"
,
approver
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/approvals"
,
approver
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'approvals_required'
]).
to
eq
2
expect
(
json_response
[
'approvals_required'
]).
to
eq
2
expect
(
json_response
[
'approvals_left'
]).
to
eq
2
expect
(
json_response
[
'approvals_left'
]).
to
eq
2
...
@@ -111,7 +111,7 @@ describe API::MergeRequestApprovals do
...
@@ -111,7 +111,7 @@ describe API::MergeRequestApprovals do
it
'hides private group'
do
it
'hides private group'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/approvals"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/approvals"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'approver_groups'
].
size
).
to
eq
(
0
)
expect
(
json_response
[
'approver_groups'
].
size
).
to
eq
(
0
)
end
end
...
@@ -119,7 +119,7 @@ describe API::MergeRequestApprovals do
...
@@ -119,7 +119,7 @@ describe API::MergeRequestApprovals do
it
'shows all approver groups'
do
it
'shows all approver groups'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/approvals"
,
admin
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/approvals"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'approver_groups'
].
size
).
to
eq
(
1
)
expect
(
json_response
[
'approver_groups'
].
size
).
to
eq
(
1
)
end
end
end
end
...
@@ -132,7 +132,7 @@ describe API::MergeRequestApprovals do
...
@@ -132,7 +132,7 @@ describe API::MergeRequestApprovals 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
)
expect
(
json_response
[
'approved'
]).
to
be
true
expect
(
json_response
[
'approved'
]).
to
be
true
expect
(
json_response
[
'message'
]).
to
eq
(
nil
)
expect
(
json_response
[
'message'
]).
to
eq
(
nil
)
end
end
...
@@ -154,7 +154,7 @@ describe API::MergeRequestApprovals do
...
@@ -154,7 +154,7 @@ describe API::MergeRequestApprovals do
it
'retrieves the approval rules details'
do
it
'retrieves the approval rules details'
do
get
api
(
url
,
user
)
get
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'rules'
].
size
).
to
eq
(
1
)
expect
(
json_response
[
'rules'
].
size
).
to
eq
(
1
)
rule_response
=
json_response
[
'rules'
].
first
rule_response
=
json_response
[
'rules'
].
first
...
@@ -182,7 +182,7 @@ describe API::MergeRequestApprovals do
...
@@ -182,7 +182,7 @@ describe API::MergeRequestApprovals do
it
'retrieves the approval state details'
do
it
'retrieves the approval state details'
do
get
api
(
url
,
user
)
get
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'rules'
].
size
).
to
eq
(
1
)
expect
(
json_response
[
'rules'
].
size
).
to
eq
(
1
)
rule_response
=
json_response
[
'rules'
].
first
rule_response
=
json_response
[
'rules'
].
first
...
@@ -207,7 +207,7 @@ describe API::MergeRequestApprovals do
...
@@ -207,7 +207,7 @@ describe API::MergeRequestApprovals do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/approvals"
,
current_user
),
params:
{
approvals_required:
5
}
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/approvals"
,
current_user
),
params:
{
approvals_required:
5
}
end
.
to
change
{
merge_request
.
reload
.
approvals_before_merge
}.
from
(
nil
).
to
(
5
)
end
.
to
change
{
merge_request
.
reload
.
approvals_before_merge
}.
from
(
nil
).
to
(
5
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'approvals_required'
]).
to
eq
(
5
)
expect
(
json_response
[
'approvals_required'
]).
to
eq
(
5
)
end
end
end
end
...
@@ -222,7 +222,7 @@ describe API::MergeRequestApprovals do
...
@@ -222,7 +222,7 @@ describe API::MergeRequestApprovals do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/approvals"
,
current_user
),
params:
{
approvals_required:
5
}
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/approvals"
,
current_user
),
params:
{
approvals_required:
5
}
end
.
not_to
change
{
merge_request
.
reload
.
approvals_before_merge
}
end
.
not_to
change
{
merge_request
.
reload
.
approvals_before_merge
}
expect
(
response
).
to
have_gitlab_http_status
(
422
)
expect
(
response
).
to
have_gitlab_http_status
(
:unprocessable_entity
)
end
end
end
end
end
end
...
@@ -251,7 +251,7 @@ describe API::MergeRequestApprovals do
...
@@ -251,7 +251,7 @@ describe API::MergeRequestApprovals do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/approvals"
,
user2
),
params:
{
approvals_required:
5
}
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/approvals"
,
user2
),
params:
{
approvals_required:
5
}
end
.
not_to
change
{
merge_request
.
reload
.
approvals_before_merge
}
end
.
not_to
change
{
merge_request
.
reload
.
approvals_before_merge
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -285,7 +285,7 @@ describe API::MergeRequestApprovals do
...
@@ -285,7 +285,7 @@ describe API::MergeRequestApprovals do
end
.
to
change
{
merge_request
.
approvers
.
count
}.
from
(
0
).
to
(
1
)
end
.
to
change
{
merge_request
.
approvers
.
count
}.
from
(
0
).
to
(
1
)
.
and
change
{
merge_request
.
approver_groups
.
count
}.
from
(
0
).
to
(
1
)
.
and
change
{
merge_request
.
approver_groups
.
count
}.
from
(
0
).
to
(
1
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'approvers'
][
0
][
'user'
][
'username'
]).
to
eq
(
approver
.
username
)
expect
(
json_response
[
'approvers'
][
0
][
'user'
][
'username'
]).
to
eq
(
approver
.
username
)
expect
(
json_response
[
'approver_groups'
][
0
][
'group'
][
'name'
]).
to
eq
(
group
.
name
)
expect
(
json_response
[
'approver_groups'
][
0
][
'group'
][
'name'
]).
to
eq
(
group
.
name
)
end
end
...
@@ -300,7 +300,7 @@ describe API::MergeRequestApprovals do
...
@@ -300,7 +300,7 @@ describe API::MergeRequestApprovals do
end
.
to
change
{
merge_request
.
approvers
.
count
}.
from
(
1
).
to
(
0
)
end
.
to
change
{
merge_request
.
approvers
.
count
}.
from
(
1
).
to
(
0
)
.
and
change
{
merge_request
.
approver_groups
.
count
}.
from
(
1
).
to
(
0
)
.
and
change
{
merge_request
.
approver_groups
.
count
}.
from
(
1
).
to
(
0
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'approvers'
]).
to
eq
([])
expect
(
json_response
[
'approvers'
]).
to
eq
([])
end
end
...
@@ -315,7 +315,7 @@ describe API::MergeRequestApprovals do
...
@@ -315,7 +315,7 @@ describe API::MergeRequestApprovals do
end
.
to
change
{
merge_request
.
approvers
.
count
}.
from
(
1
).
to
(
0
)
end
.
to
change
{
merge_request
.
approvers
.
count
}.
from
(
1
).
to
(
0
)
.
and
change
{
merge_request
.
approver_groups
.
count
}.
from
(
1
).
to
(
0
)
.
and
change
{
merge_request
.
approver_groups
.
count
}.
from
(
1
).
to
(
0
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'approvers'
]).
to
eq
([])
expect
(
json_response
[
'approvers'
]).
to
eq
([])
end
end
end
end
...
@@ -328,7 +328,7 @@ describe API::MergeRequestApprovals do
...
@@ -328,7 +328,7 @@ describe API::MergeRequestApprovals do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/approvers"
,
current_user
),
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/approvers"
,
current_user
),
params:
{
approver_ids:
[
approver
.
id
],
approver_group_ids:
[
private_group
.
id
,
group
.
id
]
}
params:
{
approver_ids:
[
approver
.
id
],
approver_group_ids:
[
private_group
.
id
,
group
.
id
]
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'approver_groups'
].
size
).
to
eq
(
expected_group_size
)
expect
(
json_response
[
'approver_groups'
].
size
).
to
eq
(
expected_group_size
)
end
end
end
end
...
@@ -358,7 +358,7 @@ describe API::MergeRequestApprovals do
...
@@ -358,7 +358,7 @@ describe API::MergeRequestApprovals do
params:
{
approver_ids:
[
approver
.
id
],
approver_group_ids:
[
group
.
id
]
}
params:
{
approver_ids:
[
approver
.
id
],
approver_group_ids:
[
group
.
id
]
}
end
.
to
not_change
{
merge_request
.
approvers
.
count
}.
and
not_change
{
merge_request
.
approver_groups
.
count
}
end
.
to
not_change
{
merge_request
.
approvers
.
count
}.
and
not_change
{
merge_request
.
approver_groups
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -372,7 +372,7 @@ describe API::MergeRequestApprovals do
...
@@ -372,7 +372,7 @@ describe API::MergeRequestApprovals do
end
end
it
'returns a 401'
do
it
'returns a 401'
do
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
...
@@ -395,7 +395,7 @@ describe API::MergeRequestApprovals do
...
@@ -395,7 +395,7 @@ describe API::MergeRequestApprovals do
end
end
it
'approves the merge request'
do
it
'approves the merge request'
do
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'approvals_left'
]).
to
eq
(
1
)
expect
(
json_response
[
'approvals_left'
]).
to
eq
(
1
)
expect
(
json_response
[
'approved_by'
][
0
][
'user'
][
'username'
]).
to
eq
(
approver
.
username
)
expect
(
json_response
[
'approved_by'
][
0
][
'user'
][
'username'
]).
to
eq
(
approver
.
username
)
expect
(
json_response
[
'user_has_approved'
]).
to
be
true
expect
(
json_response
[
'user_has_approved'
]).
to
be
true
...
@@ -409,7 +409,7 @@ describe API::MergeRequestApprovals do
...
@@ -409,7 +409,7 @@ describe API::MergeRequestApprovals do
end
end
it
'approves the merge request'
do
it
'approves the merge request'
do
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'approvals_left'
]).
to
eq
(
1
)
expect
(
json_response
[
'approvals_left'
]).
to
eq
(
1
)
expect
(
json_response
[
'approved_by'
][
0
][
'user'
][
'username'
]).
to
eq
(
approver
.
username
)
expect
(
json_response
[
'approved_by'
][
0
][
'user'
][
'username'
]).
to
eq
(
approver
.
username
)
expect
(
json_response
[
'user_has_approved'
]).
to
be
true
expect
(
json_response
[
'user_has_approved'
]).
to
be
true
...
@@ -423,7 +423,7 @@ describe API::MergeRequestApprovals do
...
@@ -423,7 +423,7 @@ describe API::MergeRequestApprovals do
end
end
it
'returns a 409'
do
it
'returns a 409'
do
expect
(
response
).
to
have_gitlab_http_status
(
409
)
expect
(
response
).
to
have_gitlab_http_status
(
:conflict
)
end
end
it
'does not approve the merge request'
do
it
'does not approve the merge request'
do
...
@@ -439,7 +439,7 @@ describe API::MergeRequestApprovals do
...
@@ -439,7 +439,7 @@ describe API::MergeRequestApprovals do
it
'returns a 401 with no password'
do
it
'returns a 401 with no password'
do
approve
approve
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
it
'does not approve the merge request with no password'
do
it
'does not approve the merge request with no password'
do
...
@@ -449,7 +449,7 @@ describe API::MergeRequestApprovals do
...
@@ -449,7 +449,7 @@ describe API::MergeRequestApprovals do
it
'returns a 401 with incorrect password'
do
it
'returns a 401 with incorrect password'
do
approve
approve
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
it
'does not approve the merge request with incorrect password'
do
it
'does not approve the merge request with incorrect password'
do
...
@@ -459,7 +459,7 @@ describe API::MergeRequestApprovals do
...
@@ -459,7 +459,7 @@ describe API::MergeRequestApprovals do
it
'approves the merge request with correct password'
do
it
'approves the merge request with correct password'
do
approve
(
approval_password:
'password'
)
approve
(
approval_password:
'password'
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
merge_request
.
reload
.
approvals_left
).
to
eq
(
1
)
expect
(
merge_request
.
reload
.
approvals_left
).
to
eq
(
1
)
end
end
end
end
...
@@ -470,7 +470,7 @@ describe API::MergeRequestApprovals do
...
@@ -470,7 +470,7 @@ describe API::MergeRequestApprovals do
approve
approve
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'approver_groups'
].
size
).
to
eq
(
0
)
expect
(
json_response
[
'approver_groups'
].
size
).
to
eq
(
0
)
end
end
end
end
...
@@ -495,7 +495,7 @@ describe API::MergeRequestApprovals do
...
@@ -495,7 +495,7 @@ describe API::MergeRequestApprovals do
it
'unapproves the merge request'
do
it
'unapproves the merge request'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/unapprove"
,
unapprover
)
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/unapprove"
,
unapprover
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'approvals_left'
]).
to
eq
(
1
)
expect
(
json_response
[
'approvals_left'
]).
to
eq
(
1
)
usernames
=
json_response
[
'approved_by'
].
map
{
|
u
|
u
[
'user'
][
'username'
]
}
usernames
=
json_response
[
'approved_by'
].
map
{
|
u
|
u
[
'user'
][
'username'
]
}
expect
(
usernames
).
not_to
include
(
unapprover
.
username
)
expect
(
usernames
).
not_to
include
(
unapprover
.
username
)
...
@@ -512,7 +512,7 @@ describe API::MergeRequestApprovals do
...
@@ -512,7 +512,7 @@ describe API::MergeRequestApprovals do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/unapprove"
,
unapprover
)
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/unapprove"
,
unapprover
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'approver_groups'
].
size
).
to
eq
(
0
)
expect
(
json_response
[
'approver_groups'
].
size
).
to
eq
(
0
)
end
end
end
end
...
...
ee/spec/requests/api/merge_requests_spec.rb
View file @
765fc43b
...
@@ -39,7 +39,7 @@ describe API::MergeRequests do
...
@@ -39,7 +39,7 @@ describe API::MergeRequests do
it
'creates merge request with multiple assignees'
do
it
'creates merge request with multiple assignees'
do
update_merge_request
(
params
)
update_merge_request
(
params
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'assignees'
].
size
).
to
eq
(
2
)
expect
(
json_response
[
'assignees'
].
size
).
to
eq
(
2
)
expect
(
json_response
[
'assignees'
].
first
[
'name'
]).
to
eq
(
user
.
name
)
expect
(
json_response
[
'assignees'
].
first
[
'name'
]).
to
eq
(
user
.
name
)
expect
(
json_response
[
'assignees'
].
second
[
'name'
]).
to
eq
(
other_user
.
name
)
expect
(
json_response
[
'assignees'
].
second
[
'name'
]).
to
eq
(
other_user
.
name
)
...
@@ -55,7 +55,7 @@ describe API::MergeRequests do
...
@@ -55,7 +55,7 @@ describe API::MergeRequests do
it
'creates merge request with a single assignee'
do
it
'creates merge request with a single assignee'
do
update_merge_request
(
params
)
update_merge_request
(
params
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'assignees'
].
size
).
to
eq
(
1
)
expect
(
json_response
[
'assignees'
].
size
).
to
eq
(
1
)
expect
(
json_response
[
'assignees'
].
first
[
'name'
]).
to
eq
(
user
.
name
)
expect
(
json_response
[
'assignees'
].
first
[
'name'
]).
to
eq
(
user
.
name
)
expect
(
json_response
.
dig
(
'assignee'
,
'name'
)).
to
eq
(
user
.
name
)
expect
(
json_response
.
dig
(
'assignee'
,
'name'
)).
to
eq
(
user
.
name
)
...
@@ -74,7 +74,7 @@ describe API::MergeRequests do
...
@@ -74,7 +74,7 @@ describe API::MergeRequests do
]
]
)
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
merge_request
.
reload
merge_request
.
reload
...
@@ -107,7 +107,7 @@ describe API::MergeRequests do
...
@@ -107,7 +107,7 @@ describe API::MergeRequests do
it
'creates merge request with multiple assignees'
do
it
'creates merge request with multiple assignees'
do
create_merge_request
(
assignee_ids:
[
user
.
id
,
user2
.
id
])
create_merge_request
(
assignee_ids:
[
user
.
id
,
user2
.
id
])
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'assignees'
].
size
).
to
eq
(
2
)
expect
(
json_response
[
'assignees'
].
size
).
to
eq
(
2
)
expect
(
json_response
[
'assignees'
].
first
[
'name'
]).
to
eq
(
user
.
name
)
expect
(
json_response
[
'assignees'
].
first
[
'name'
]).
to
eq
(
user
.
name
)
expect
(
json_response
[
'assignees'
].
second
[
'name'
]).
to
eq
(
user2
.
name
)
expect
(
json_response
[
'assignees'
].
second
[
'name'
]).
to
eq
(
user2
.
name
)
...
@@ -123,7 +123,7 @@ describe API::MergeRequests do
...
@@ -123,7 +123,7 @@ describe API::MergeRequests do
it
'creates merge request with a single assignee'
do
it
'creates merge request with a single assignee'
do
create_merge_request
(
assignee_ids:
[
user
.
id
,
user2
.
id
])
create_merge_request
(
assignee_ids:
[
user
.
id
,
user2
.
id
])
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'assignees'
].
size
).
to
eq
(
1
)
expect
(
json_response
[
'assignees'
].
size
).
to
eq
(
1
)
expect
(
json_response
[
'assignees'
].
first
[
'name'
]).
to
eq
(
user
.
name
)
expect
(
json_response
[
'assignees'
].
first
[
'name'
]).
to
eq
(
user
.
name
)
expect
(
json_response
.
dig
(
'assignee'
,
'name'
)).
to
eq
(
user
.
name
)
expect
(
json_response
.
dig
(
'assignee'
,
'name'
)).
to
eq
(
user
.
name
)
...
@@ -135,7 +135,7 @@ describe API::MergeRequests do
...
@@ -135,7 +135,7 @@ describe API::MergeRequests do
it
"returns merge_request"
do
it
"returns merge_request"
do
create_merge_request
(
squash:
true
)
create_merge_request
(
squash:
true
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'title'
]).
to
eq
(
'Test merge_request'
)
expect
(
json_response
[
'title'
]).
to
eq
(
'Test merge_request'
)
expect
(
json_response
[
'labels'
]).
to
eq
(
%w(label label2)
)
expect
(
json_response
[
'labels'
]).
to
eq
(
%w(label label2)
)
expect
(
json_response
[
'milestone'
][
'id'
]).
to
eq
(
milestone
.
id
)
expect
(
json_response
[
'milestone'
][
'id'
]).
to
eq
(
milestone
.
id
)
...
@@ -162,7 +162,7 @@ describe API::MergeRequests do
...
@@ -162,7 +162,7 @@ describe API::MergeRequests do
end
end
it
'sets approvals_before_merge'
do
it
'sets approvals_before_merge'
do
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'message'
]).
to
eq
(
nil
)
expect
(
json_response
[
'message'
]).
to
eq
(
nil
)
expect
(
json_response
[
'approvals_before_merge'
]).
to
eq
(
1
)
expect
(
json_response
[
'approvals_before_merge'
]).
to
eq
(
1
)
end
end
...
@@ -178,7 +178,7 @@ describe API::MergeRequests do
...
@@ -178,7 +178,7 @@ describe API::MergeRequests do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
406
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_acceptable
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Branch cannot be merged'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Branch cannot be merged'
)
end
end
...
@@ -190,7 +190,7 @@ describe API::MergeRequests do
...
@@ -190,7 +190,7 @@ describe API::MergeRequests do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
...
@@ -261,7 +261,7 @@ describe API::MergeRequests do
...
@@ -261,7 +261,7 @@ describe API::MergeRequests do
let
(
:approvers_param
)
{
'any-other-string'
}
let
(
:approvers_param
)
{
'any-other-string'
}
it
'returns a validation error'
do
it
'returns a validation error'
do
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'error'
]).
to
eq
(
"approver_ids should be an array, 'None' or 'Any'"
)
expect
(
json_response
[
'error'
]).
to
eq
(
"approver_ids should be an array, 'None' or 'Any'"
)
end
end
end
end
...
@@ -306,7 +306,7 @@ describe API::MergeRequests do
...
@@ -306,7 +306,7 @@ describe API::MergeRequests do
let
(
:approvals_param
)
{
'any-other-string'
}
let
(
:approvals_param
)
{
'any-other-string'
}
it
'returns a validation error'
do
it
'returns a validation error'
do
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'error'
]).
to
eq
(
"approved_by_ids should be an array, 'None' or 'Any'"
)
expect
(
json_response
[
'error'
]).
to
eq
(
"approved_by_ids should be an array, 'None' or 'Any'"
)
end
end
end
end
...
...
ee/spec/requests/api/namespaces_spec.rb
View file @
765fc43b
...
@@ -17,7 +17,7 @@ describe API::Namespaces do
...
@@ -17,7 +17,7 @@ describe API::Namespaces do
group_kind_json_response
=
json_response
.
find
{
|
resource
|
resource
[
'kind'
]
==
'group'
}
group_kind_json_response
=
json_response
.
find
{
|
resource
|
resource
[
'kind'
]
==
'group'
}
user_kind_json_response
=
json_response
.
find
{
|
resource
|
resource
[
'kind'
]
==
'user'
}
user_kind_json_response
=
json_response
.
find
{
|
resource
|
resource
[
'kind'
]
==
'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
(
group_kind_json_response
.
keys
).
to
contain_exactly
(
'id'
,
'kind'
,
'name'
,
'path'
,
'full_path'
,
expect
(
group_kind_json_response
.
keys
).
to
contain_exactly
(
'id'
,
'kind'
,
'name'
,
'path'
,
'full_path'
,
'parent_id'
,
'members_count_with_descendants'
,
'parent_id'
,
'members_count_with_descendants'
,
...
@@ -120,7 +120,7 @@ describe API::Namespaces do
...
@@ -120,7 +120,7 @@ describe API::Namespaces do
put
api
(
"/namespaces/
#{
group1
.
full_path
}
"
,
admin
),
params:
{
plan:
'silver'
,
shared_runners_minutes_limit:
9001
}
put
api
(
"/namespaces/
#{
group1
.
full_path
}
"
,
admin
),
params:
{
plan:
'silver'
,
shared_runners_minutes_limit:
9001
}
aggregate_failures
do
aggregate_failures
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'plan'
]).
to
eq
(
'silver'
)
expect
(
json_response
[
'plan'
]).
to
eq
(
'silver'
)
expect
(
json_response
[
'shared_runners_minutes_limit'
]).
to
eq
(
9001
)
expect
(
json_response
[
'shared_runners_minutes_limit'
]).
to
eq
(
9001
)
end
end
...
@@ -129,7 +129,7 @@ describe API::Namespaces do
...
@@ -129,7 +129,7 @@ describe API::Namespaces do
it
'updates namespace using id'
do
it
'updates namespace using id'
do
put
api
(
"/namespaces/
#{
group1
.
id
}
"
,
admin
),
params:
{
plan:
'silver'
,
shared_runners_minutes_limit:
9001
}
put
api
(
"/namespaces/
#{
group1
.
id
}
"
,
admin
),
params:
{
plan:
'silver'
,
shared_runners_minutes_limit:
9001
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'plan'
]).
to
eq
(
'silver'
)
expect
(
json_response
[
'plan'
]).
to
eq
(
'silver'
)
expect
(
json_response
[
'shared_runners_minutes_limit'
]).
to
eq
(
9001
)
expect
(
json_response
[
'shared_runners_minutes_limit'
]).
to
eq
(
9001
)
end
end
...
@@ -139,7 +139,7 @@ describe API::Namespaces do
...
@@ -139,7 +139,7 @@ describe API::Namespaces do
it
'retuns 403'
do
it
'retuns 403'
do
put
api
(
"/namespaces/
#{
group1
.
id
}
"
,
user
),
params:
{
plan:
'silver'
}
put
api
(
"/namespaces/
#{
group1
.
id
}
"
,
user
),
params:
{
plan:
'silver'
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -147,7 +147,7 @@ describe API::Namespaces do
...
@@ -147,7 +147,7 @@ describe API::Namespaces do
it
'returns 404'
do
it
'returns 404'
do
put
api
(
"/namespaces/12345"
,
admin
),
params:
{
plan:
'silver'
}
put
api
(
"/namespaces/12345"
,
admin
),
params:
{
plan:
'silver'
}
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
json_response
).
to
eq
(
'message'
=>
'404 Namespace Not Found'
)
expect
(
json_response
).
to
eq
(
'message'
=>
'404 Namespace Not Found'
)
end
end
end
end
...
@@ -156,7 +156,7 @@ describe API::Namespaces do
...
@@ -156,7 +156,7 @@ describe API::Namespaces do
it
'returns validation error'
do
it
'returns validation error'
do
put
api
(
"/namespaces/
#{
group1
.
id
}
"
,
admin
),
params:
{
plan:
'unknown'
}
put
api
(
"/namespaces/
#{
group1
.
id
}
"
,
admin
),
params:
{
plan:
'unknown'
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
]).
to
eq
(
'plan'
=>
[
'is not included in the list'
])
expect
(
json_response
[
'message'
]).
to
eq
(
'plan'
=>
[
'is not included in the list'
])
end
end
end
end
...
@@ -202,7 +202,7 @@ describe API::Namespaces do
...
@@ -202,7 +202,7 @@ describe API::Namespaces do
it
'returns an unauthroized error'
do
it
'returns an unauthroized error'
do
do_post
(
user
,
params
)
do_post
(
user
,
params
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -210,13 +210,13 @@ describe API::Namespaces do
...
@@ -210,13 +210,13 @@ describe API::Namespaces do
it
'fails when some attrs are missing'
do
it
'fails when some attrs are missing'
do
do_post
(
admin
,
params
.
except
(
:start_date
))
do_post
(
admin
,
params
.
except
(
:start_date
))
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
'creates a subscription for the Group'
do
it
'creates a subscription for the Group'
do
do_post
(
admin
,
params
)
do_post
(
admin
,
params
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
group1
.
gitlab_subscription
).
to
be_present
expect
(
group1
.
gitlab_subscription
).
to
be_present
end
end
...
@@ -231,7 +231,7 @@ describe API::Namespaces do
...
@@ -231,7 +231,7 @@ describe API::Namespaces do
post
api
(
"/namespaces/
#{
group1
.
full_path
}
/gitlab_subscription"
,
admin
),
params:
params
post
api
(
"/namespaces/
#{
group1
.
full_path
}
/gitlab_subscription"
,
admin
),
params:
params
aggregate_failures
do
aggregate_failures
do
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
group1
.
gitlab_subscription
).
to
be_present
expect
(
group1
.
gitlab_subscription
).
to
be_present
end
end
end
end
...
@@ -258,7 +258,7 @@ describe API::Namespaces do
...
@@ -258,7 +258,7 @@ describe API::Namespaces do
it
'returns an unauthroized error'
do
it
'returns an unauthroized error'
do
do_get
(
developer
)
do_get
(
developer
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -266,13 +266,13 @@ describe API::Namespaces do
...
@@ -266,13 +266,13 @@ describe API::Namespaces do
it
'has access to the object'
do
it
'has access to the object'
do
do_get
(
owner
)
do_get
(
owner
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'is successful using full_path when namespace path contains dots'
do
it
'is successful using full_path when namespace path contains dots'
do
get
api
(
"/namespaces/
#{
group1
.
full_path
}
/gitlab_subscription"
,
admin
)
get
api
(
"/namespaces/
#{
group1
.
full_path
}
/gitlab_subscription"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'returns data in a proper format'
do
it
'returns data in a proper format'
do
...
@@ -312,7 +312,7 @@ describe API::Namespaces do
...
@@ -312,7 +312,7 @@ describe API::Namespaces do
it
'returns an unauthroized error'
do
it
'returns an unauthroized error'
do
do_put
(
namespace
.
id
,
user
,
{
seats:
150
})
do_put
(
namespace
.
id
,
user
,
{
seats:
150
})
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -321,7 +321,7 @@ describe API::Namespaces do
...
@@ -321,7 +321,7 @@ describe API::Namespaces do
it
'returns a 404 error'
,
:quarantine
do
it
'returns a 404 error'
,
:quarantine
do
do_put
(
1111
,
admin
,
params
)
do_put
(
1111
,
admin
,
params
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -331,7 +331,7 @@ describe API::Namespaces do
...
@@ -331,7 +331,7 @@ describe API::Namespaces do
it
'returns a 404 error'
do
it
'returns a 404 error'
do
do_put
(
namespace_2
.
id
,
admin
,
params
)
do_put
(
namespace_2
.
id
,
admin
,
params
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -339,7 +339,7 @@ describe API::Namespaces do
...
@@ -339,7 +339,7 @@ describe API::Namespaces do
it
'returns a 400 error'
do
it
'returns a 400 error'
do
do_put
(
namespace
.
id
,
admin
,
params
.
merge
(
seats:
nil
))
do_put
(
namespace
.
id
,
admin
,
params
.
merge
(
seats:
nil
))
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
...
@@ -347,7 +347,7 @@ describe API::Namespaces do
...
@@ -347,7 +347,7 @@ describe API::Namespaces do
it
'updates the subscription for the Group'
do
it
'updates the subscription for the Group'
do
do_put
(
namespace
.
id
,
admin
,
params
)
do_put
(
namespace
.
id
,
admin
,
params
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
gitlab_subscription
.
reload
.
seats
).
to
eq
(
150
)
expect
(
gitlab_subscription
.
reload
.
seats
).
to
eq
(
150
)
expect
(
gitlab_subscription
.
plan_name
).
to
eq
(
'silver'
)
expect
(
gitlab_subscription
.
plan_name
).
to
eq
(
'silver'
)
expect
(
gitlab_subscription
.
plan_title
).
to
eq
(
'Silver'
)
expect
(
gitlab_subscription
.
plan_title
).
to
eq
(
'Silver'
)
...
@@ -356,7 +356,7 @@ describe API::Namespaces do
...
@@ -356,7 +356,7 @@ describe API::Namespaces do
it
'is sucessful using full_path when namespace path contains dots'
do
it
'is sucessful using full_path when namespace path contains dots'
do
put
api
(
"/namespaces/
#{
namespace
.
full_path
}
/gitlab_subscription"
,
admin
),
params:
params
put
api
(
"/namespaces/
#{
namespace
.
full_path
}
/gitlab_subscription"
,
admin
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
end
end
...
@@ -368,7 +368,7 @@ describe API::Namespaces do
...
@@ -368,7 +368,7 @@ describe API::Namespaces do
do_put
(
namespace
.
id
,
admin
,
params
.
merge
(
trial_ends_on:
date
))
do_put
(
namespace
.
id
,
admin
,
params
.
merge
(
trial_ends_on:
date
))
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
gitlab_subscription
.
reload
.
trial_ends_on
).
to
eq
(
date
)
expect
(
gitlab_subscription
.
reload
.
trial_ends_on
).
to
eq
(
date
)
end
end
end
end
...
@@ -377,7 +377,7 @@ describe API::Namespaces do
...
@@ -377,7 +377,7 @@ describe API::Namespaces do
it
'returns 400'
do
it
'returns 400'
do
do_put
(
namespace
.
id
,
admin
,
params
.
merge
(
trial_ends_on:
2
.
days
.
ago
.
to_date
))
do_put
(
namespace
.
id
,
admin
,
params
.
merge
(
trial_ends_on:
2
.
days
.
ago
.
to_date
))
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
gitlab_subscription
.
reload
.
trial_ends_on
).
to
be_nil
expect
(
gitlab_subscription
.
reload
.
trial_ends_on
).
to
be_nil
end
end
end
end
...
...
ee/spec/requests/api/notes_spec.rb
View file @
765fc43b
...
@@ -40,7 +40,7 @@ describe API::Notes do
...
@@ -40,7 +40,7 @@ describe API::Notes do
it
'returns previous issue system notes'
do
it
'returns previous issue system notes'
do
get
api
(
"/groups/
#{
group
.
id
}
/epics/
#{
promoted_issue_epic
.
id
}
/notes"
,
reporter
)
get
api
(
"/groups/
#{
group
.
id
}
/epics/
#{
promoted_issue_epic
.
id
}
/notes"
,
reporter
)
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
)
...
@@ -51,7 +51,7 @@ describe API::Notes do
...
@@ -51,7 +51,7 @@ describe API::Notes do
it
'does not return previous issue system notes'
do
it
'does not return previous issue system notes'
do
get
api
(
"/groups/
#{
group
.
id
}
/epics/
#{
promoted_issue_epic
.
id
}
/notes"
,
guest
)
get
api
(
"/groups/
#{
group
.
id
}
/epics/
#{
promoted_issue_epic
.
id
}
/notes"
,
guest
)
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
)
...
...
ee/spec/requests/api/npm_packages_spec.rb
View file @
765fc43b
...
@@ -30,7 +30,7 @@ describe API::NpmPackages do
...
@@ -30,7 +30,7 @@ describe API::NpmPackages do
it
'denies request without oauth token'
do
it
'denies request without oauth token'
do
get_package
(
package
)
get_package
(
package
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -80,7 +80,7 @@ describe API::NpmPackages do
...
@@ -80,7 +80,7 @@ describe API::NpmPackages do
get_package_with_token
(
package
)
get_package_with_token
(
package
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -89,7 +89,7 @@ describe API::NpmPackages do
...
@@ -89,7 +89,7 @@ describe API::NpmPackages do
get_package
(
package
)
get_package
(
package
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
def
get_package
(
package
,
params
=
{})
def
get_package
(
package
,
params
=
{})
...
@@ -113,21 +113,21 @@ describe API::NpmPackages do
...
@@ -113,21 +113,21 @@ describe API::NpmPackages do
it
'returns the file with an access token'
do
it
'returns the file with an access token'
do
get_file_with_token
(
package_file
)
get_file_with_token
(
package_file
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
.
media_type
).
to
eq
(
'application/octet-stream'
)
expect
(
response
.
media_type
).
to
eq
(
'application/octet-stream'
)
end
end
it
'returns the file with a job token'
do
it
'returns the file with a job token'
do
get_file_with_job_token
(
package_file
)
get_file_with_job_token
(
package_file
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
.
media_type
).
to
eq
(
'application/octet-stream'
)
expect
(
response
.
media_type
).
to
eq
(
'application/octet-stream'
)
end
end
it
'denies download with no token'
do
it
'denies download with no token'
do
get_file
(
package_file
)
get_file
(
package_file
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -137,7 +137,7 @@ describe API::NpmPackages do
...
@@ -137,7 +137,7 @@ describe API::NpmPackages do
it
'returns the file with no token needed'
do
it
'returns the file with no token needed'
do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
.
media_type
).
to
eq
(
'application/octet-stream'
)
expect
(
response
.
media_type
).
to
eq
(
'application/octet-stream'
)
end
end
...
@@ -156,7 +156,7 @@ describe API::NpmPackages do
...
@@ -156,7 +156,7 @@ describe API::NpmPackages do
get_file_with_token
(
package_file
)
get_file_with_token
(
package_file
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -173,7 +173,7 @@ describe API::NpmPackages do
...
@@ -173,7 +173,7 @@ describe API::NpmPackages do
get_file
(
package_file
)
get_file
(
package_file
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
def
get_file
(
package_file
,
params
=
{})
def
get_file
(
package_file
,
params
=
{})
...
@@ -201,7 +201,7 @@ describe API::NpmPackages do
...
@@ -201,7 +201,7 @@ describe API::NpmPackages do
expect
{
upload_package_with_token
(
package_name
,
params
)
}
expect
{
upload_package_with_token
(
package_name
,
params
)
}
.
not_to
change
{
project
.
packages
.
count
}
.
not_to
change
{
project
.
packages
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
context
'with empty versions'
do
context
'with empty versions'
do
...
@@ -211,7 +211,7 @@ describe API::NpmPackages do
...
@@ -211,7 +211,7 @@ describe API::NpmPackages do
expect
{
upload_package_with_token
(
package_name
,
params
)
}
expect
{
upload_package_with_token
(
package_name
,
params
)
}
.
not_to
change
{
project
.
packages
.
count
}
.
not_to
change
{
project
.
packages
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
end
end
...
@@ -224,7 +224,7 @@ describe API::NpmPackages do
...
@@ -224,7 +224,7 @@ describe API::NpmPackages do
expect
{
upload_package_with_token
(
package_name
,
params
)
}
expect
{
upload_package_with_token
(
package_name
,
params
)
}
.
not_to
change
{
project
.
packages
.
count
}
.
not_to
change
{
project
.
packages
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
end
end
...
@@ -244,7 +244,7 @@ describe API::NpmPackages do
...
@@ -244,7 +244,7 @@ describe API::NpmPackages do
.
and
change
{
Packages
::
PackageFile
.
count
}.
by
(
1
)
.
and
change
{
Packages
::
PackageFile
.
count
}.
by
(
1
)
.
and
change
{
Packages
::
Tag
.
count
}.
by
(
1
)
.
and
change
{
Packages
::
Tag
.
count
}.
by
(
1
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
...
@@ -253,7 +253,7 @@ describe API::NpmPackages do
...
@@ -253,7 +253,7 @@ describe API::NpmPackages do
.
to
change
{
project
.
packages
.
count
}.
by
(
1
)
.
to
change
{
project
.
packages
.
count
}.
by
(
1
)
.
and
change
{
Packages
::
PackageFile
.
count
}.
by
(
1
)
.
and
change
{
Packages
::
PackageFile
.
count
}.
by
(
1
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
context
'with an authenticated job token'
do
context
'with an authenticated job token'
do
...
@@ -272,7 +272,7 @@ describe API::NpmPackages do
...
@@ -272,7 +272,7 @@ describe API::NpmPackages do
it
'creates the package metadata'
do
it
'creates the package metadata'
do
upload_package_with_token
(
package_name
,
params
)
upload_package_with_token
(
package_name
,
params
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
project
.
reload
.
packages
.
find
(
json_response
[
'id'
]).
build_info
.
pipeline
).
to
eq
job
.
pipeline
expect
(
project
.
reload
.
packages
.
find
(
json_response
[
'id'
]).
build_info
.
pipeline
).
to
eq
job
.
pipeline
end
end
end
end
...
@@ -287,7 +287,7 @@ describe API::NpmPackages do
...
@@ -287,7 +287,7 @@ describe API::NpmPackages do
expect
{
upload_package_with_token
(
package_name
,
params
)
}
expect
{
upload_package_with_token
(
package_name
,
params
)
}
.
not_to
change
{
project
.
packages
.
count
}
.
not_to
change
{
project
.
packages
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -302,7 +302,7 @@ describe API::NpmPackages do
...
@@ -302,7 +302,7 @@ describe API::NpmPackages do
.
and
change
{
Packages
::
Dependency
.
count
}.
by
(
4
)
.
and
change
{
Packages
::
Dependency
.
count
}.
by
(
4
)
.
and
change
{
Packages
::
DependencyLink
.
count
}.
by
(
6
)
.
and
change
{
Packages
::
DependencyLink
.
count
}.
by
(
6
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
context
'with existing dependencies'
do
context
'with existing dependencies'
do
...
@@ -513,7 +513,7 @@ describe API::NpmPackages do
...
@@ -513,7 +513,7 @@ describe API::NpmPackages do
end
end
def
expect_a_valid_package_response
def
expect_a_valid_package_response
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
.
media_type
).
to
eq
(
'application/json'
)
expect
(
response
.
media_type
).
to
eq
(
'application/json'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/packages/npm_package'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/packages/npm_package'
,
dir:
'ee'
)
expect
(
json_response
[
'name'
]).
to
eq
(
package
.
name
)
expect
(
json_response
[
'name'
]).
to
eq
(
package
.
name
)
...
...
spec/requests/api/markdown_spec.rb
View file @
765fc43b
...
@@ -16,7 +16,7 @@ describe API::Markdown do
...
@@ -16,7 +16,7 @@ describe API::Markdown do
shared_examples
"rendered markdown text without GFM"
do
shared_examples
"rendered markdown text without GFM"
do
it
"renders markdown text"
do
it
"renders markdown text"
do
expect
(
response
).
to
have_
http_status
(
201
)
expect
(
response
).
to
have_
gitlab_http_status
(
:created
)
expect
(
response
.
headers
[
"Content-Type"
]).
to
eq
(
"application/json"
)
expect
(
response
.
headers
[
"Content-Type"
]).
to
eq
(
"application/json"
)
expect
(
json_response
).
to
be_a
(
Hash
)
expect
(
json_response
).
to
be_a
(
Hash
)
expect
(
json_response
[
"html"
]).
to
eq
(
"<p>
#{
text
}
</p>"
)
expect
(
json_response
[
"html"
]).
to
eq
(
"<p>
#{
text
}
</p>"
)
...
@@ -25,7 +25,7 @@ describe API::Markdown do
...
@@ -25,7 +25,7 @@ describe API::Markdown do
shared_examples
"404 Project Not Found"
do
shared_examples
"404 Project Not Found"
do
it
"responses with 404 Not Found"
do
it
"responses with 404 Not Found"
do
expect
(
response
).
to
have_
http_status
(
404
)
expect
(
response
).
to
have_
gitlab_http_status
(
:not_found
)
expect
(
response
.
headers
[
"Content-Type"
]).
to
eq
(
"application/json"
)
expect
(
response
.
headers
[
"Content-Type"
]).
to
eq
(
"application/json"
)
expect
(
json_response
).
to
be_a
(
Hash
)
expect
(
json_response
).
to
be_a
(
Hash
)
expect
(
json_response
[
"message"
]).
to
eq
(
"404 Project Not Found"
)
expect
(
json_response
[
"message"
]).
to
eq
(
"404 Project Not Found"
)
...
@@ -37,7 +37,7 @@ describe API::Markdown do
...
@@ -37,7 +37,7 @@ describe API::Markdown do
let
(
:params
)
{
{}
}
let
(
:params
)
{
{}
}
it
"responses with 400 Bad Request"
do
it
"responses with 400 Bad Request"
do
expect
(
response
).
to
have_
http_status
(
400
)
expect
(
response
).
to
have_
gitlab_http_status
(
:bad_request
)
expect
(
response
.
headers
[
"Content-Type"
]).
to
eq
(
"application/json"
)
expect
(
response
.
headers
[
"Content-Type"
]).
to
eq
(
"application/json"
)
expect
(
json_response
).
to
be_a
(
Hash
)
expect
(
json_response
).
to
be_a
(
Hash
)
expect
(
json_response
[
"error"
]).
to
eq
(
"text is missing"
)
expect
(
json_response
[
"error"
]).
to
eq
(
"text is missing"
)
...
@@ -83,7 +83,7 @@ describe API::Markdown do
...
@@ -83,7 +83,7 @@ describe API::Markdown do
let
(
:params
)
{
{
text:
text
,
gfm:
true
}
}
let
(
:params
)
{
{
text:
text
,
gfm:
true
}
}
it
"renders markdown text"
do
it
"renders markdown text"
do
expect
(
response
).
to
have_
http_status
(
201
)
expect
(
response
).
to
have_
gitlab_http_status
(
:created
)
expect
(
response
.
headers
[
"Content-Type"
]).
to
eq
(
"application/json"
)
expect
(
response
.
headers
[
"Content-Type"
]).
to
eq
(
"application/json"
)
expect
(
json_response
).
to
be_a
(
Hash
)
expect
(
json_response
).
to
be_a
(
Hash
)
expect
(
json_response
[
"html"
]).
to
include
(
"Hello world!"
)
expect
(
json_response
[
"html"
]).
to
include
(
"Hello world!"
)
...
@@ -100,7 +100,7 @@ describe API::Markdown do
...
@@ -100,7 +100,7 @@ describe API::Markdown do
let
(
:user
)
{
project
.
owner
}
let
(
:user
)
{
project
.
owner
}
it
"renders markdown text"
do
it
"renders markdown text"
do
expect
(
response
).
to
have_
http_status
(
201
)
expect
(
response
).
to
have_
gitlab_http_status
(
:created
)
expect
(
response
.
headers
[
"Content-Type"
]).
to
eq
(
"application/json"
)
expect
(
response
.
headers
[
"Content-Type"
]).
to
eq
(
"application/json"
)
expect
(
json_response
).
to
be_a
(
Hash
)
expect
(
json_response
).
to
be_a
(
Hash
)
expect
(
json_response
[
"html"
]).
to
include
(
"Hello world!"
)
expect
(
json_response
[
"html"
]).
to
include
(
"Hello world!"
)
...
@@ -120,7 +120,7 @@ describe API::Markdown do
...
@@ -120,7 +120,7 @@ describe API::Markdown do
shared_examples
'user without proper access'
do
shared_examples
'user without proper access'
do
it
'does not render the title or link'
do
it
'does not render the title or link'
do
expect
(
response
).
to
have_
http_status
(
201
)
expect
(
response
).
to
have_
gitlab_http_status
(
:created
)
expect
(
json_response
[
"html"
]).
not_to
include
(
'Confidential title'
)
expect
(
json_response
[
"html"
]).
not_to
include
(
'Confidential title'
)
expect
(
json_response
[
"html"
]).
not_to
include
(
'<a href='
)
expect
(
json_response
[
"html"
]).
not_to
include
(
'<a href='
)
expect
(
json_response
[
"html"
]).
to
include
(
'Hello world!'
)
expect
(
json_response
[
"html"
]).
to
include
(
'Hello world!'
)
...
@@ -146,7 +146,7 @@ describe API::Markdown do
...
@@ -146,7 +146,7 @@ describe API::Markdown do
let
(
:user
)
{
confidential_issue
.
author
}
let
(
:user
)
{
confidential_issue
.
author
}
it
'renders the title or link'
do
it
'renders the title or link'
do
expect
(
response
).
to
have_
http_status
(
201
)
expect
(
response
).
to
have_
gitlab_http_status
(
:created
)
expect
(
json_response
[
"html"
]).
to
include
(
'Confidential title'
)
expect
(
json_response
[
"html"
]).
to
include
(
'Confidential title'
)
expect
(
json_response
[
"html"
]).
to
include
(
'Hello world!'
)
expect
(
json_response
[
"html"
]).
to
include
(
'Hello world!'
)
.
and
include
(
'data-name="tada"'
)
.
and
include
(
'data-name="tada"'
)
...
...
spec/requests/api/members_spec.rb
View file @
765fc43b
...
@@ -43,7 +43,7 @@ describe API::Members do
...
@@ -43,7 +43,7 @@ describe API::Members do
get
api
(
members_url
,
user
)
get
api
(
members_url
,
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
)
...
@@ -72,7 +72,7 @@ describe API::Members do
...
@@ -72,7 +72,7 @@ describe API::Members do
get
api
(
members_url
,
developer
)
get
api
(
members_url
,
developer
)
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
)
...
@@ -82,7 +82,7 @@ describe API::Members do
...
@@ -82,7 +82,7 @@ describe API::Members do
it
'finds members with query string'
do
it
'finds members with query string'
do
get
api
(
members_url
,
developer
),
params:
{
query:
maintainer
.
username
}
get
api
(
members_url
,
developer
),
params:
{
query:
maintainer
.
username
}
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
.
count
).
to
eq
(
1
)
expect
(
json_response
.
count
).
to
eq
(
1
)
...
@@ -92,7 +92,7 @@ describe API::Members do
...
@@ -92,7 +92,7 @@ describe API::Members do
it
'finds members with the given user_ids'
do
it
'finds members with the given user_ids'
do
get
api
(
members_url
,
developer
),
params:
{
user_ids:
[
maintainer
.
id
,
developer
.
id
,
stranger
.
id
]
}
get
api
(
members_url
,
developer
),
params:
{
user_ids:
[
maintainer
.
id
,
developer
.
id
,
stranger
.
id
]
}
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
{
|
u
|
u
[
'id'
]
}).
to
contain_exactly
(
maintainer
.
id
,
developer
.
id
)
expect
(
json_response
.
map
{
|
u
|
u
[
'id'
]
}).
to
contain_exactly
(
maintainer
.
id
,
developer
.
id
)
...
@@ -101,7 +101,7 @@ describe API::Members do
...
@@ -101,7 +101,7 @@ describe API::Members do
it
'finds all members with no query specified'
do
it
'finds all members with no query specified'
do
get
api
(
members_url
,
developer
),
params:
{
query:
''
}
get
api
(
members_url
,
developer
),
params:
{
query:
''
}
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
.
count
).
to
eq
(
2
)
expect
(
json_response
.
count
).
to
eq
(
2
)
...
@@ -137,7 +137,7 @@ describe API::Members do
...
@@ -137,7 +137,7 @@ describe API::Members do
it
'finds all project members including inherited members'
do
it
'finds all project members including inherited members'
do
get
api
(
"/projects/
#{
project
.
id
}
/members/all"
,
developer
)
get
api
(
"/projects/
#{
project
.
id
}
/members/all"
,
developer
)
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
{
|
u
|
u
[
'id'
]
}).
to
match_array
[
maintainer
.
id
,
developer
.
id
,
nested_user
.
id
,
project_user
.
id
,
linked_group_user
.
id
]
expect
(
json_response
.
map
{
|
u
|
u
[
'id'
]
}).
to
match_array
[
maintainer
.
id
,
developer
.
id
,
nested_user
.
id
,
project_user
.
id
,
linked_group_user
.
id
]
...
@@ -148,7 +148,7 @@ describe API::Members do
...
@@ -148,7 +148,7 @@ describe API::Members do
get
api
(
"/projects/
#{
project
.
id
}
/members/all"
,
developer
)
get
api
(
"/projects/
#{
project
.
id
}
/members/all"
,
developer
)
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
...
@@ -165,7 +165,7 @@ describe API::Members do
...
@@ -165,7 +165,7 @@ describe API::Members do
it
'finds all group members including inherited members'
do
it
'finds all group members including inherited members'
do
get
api
(
"/groups/
#{
nested_group
.
id
}
/members/all"
,
developer
)
get
api
(
"/groups/
#{
nested_group
.
id
}
/members/all"
,
developer
)
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
{
|
u
|
u
[
'id'
]
}).
to
match_array
[
maintainer
.
id
,
developer
.
id
,
nested_user
.
id
]
expect
(
json_response
.
map
{
|
u
|
u
[
'id'
]
}).
to
match_array
[
maintainer
.
id
,
developer
.
id
,
nested_user
.
id
]
...
@@ -185,7 +185,7 @@ describe API::Members do
...
@@ -185,7 +185,7 @@ describe API::Members do
user
=
public_send
(
type
)
user
=
public_send
(
type
)
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/
#{
all
?
'all/'
:
''
}#{
developer
.
id
}
"
,
user
)
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/
#{
all
?
'all/'
:
''
}#{
developer
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
# User attributes
# User attributes
expect
(
json_response
[
'id'
]).
to
eq
(
developer
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
developer
.
id
)
expect
(
json_response
[
'name'
]).
to
eq
(
developer
.
name
)
expect
(
json_response
[
'name'
]).
to
eq
(
developer
.
name
)
...
@@ -220,7 +220,7 @@ describe API::Members do
...
@@ -220,7 +220,7 @@ describe API::Members do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
user
),
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
user
),
params:
{
user_id:
access_requester
.
id
,
access_level:
Member
::
MAINTAINER
}
params:
{
user_id:
access_requester
.
id
,
access_level:
Member
::
MAINTAINER
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -233,7 +233,7 @@ describe API::Members do
...
@@ -233,7 +233,7 @@ describe API::Members do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
params:
{
user_id:
access_requester
.
id
,
access_level:
Member
::
MAINTAINER
}
params:
{
user_id:
access_requester
.
id
,
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
)
expect
(
source
.
requesters
.
count
).
to
eq
(
0
)
expect
(
source
.
requesters
.
count
).
to
eq
(
0
)
expect
(
json_response
[
'id'
]).
to
eq
(
access_requester
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
access_requester
.
id
)
...
@@ -246,7 +246,7 @@ describe API::Members do
...
@@ -246,7 +246,7 @@ describe API::Members do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
params:
{
user_id:
stranger
.
id
,
access_level:
Member
::
DEVELOPER
,
expires_at:
'2016-08-05'
}
params:
{
user_id:
stranger
.
id
,
access_level:
Member
::
DEVELOPER
,
expires_at:
'2016-08-05'
}
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
)
expect
(
json_response
[
'id'
]).
to
eq
(
stranger
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
stranger
.
id
)
expect
(
json_response
[
'access_level'
]).
to
eq
(
Member
::
DEVELOPER
)
expect
(
json_response
[
'access_level'
]).
to
eq
(
Member
::
DEVELOPER
)
...
@@ -265,7 +265,7 @@ describe API::Members do
...
@@ -265,7 +265,7 @@ describe API::Members do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
params:
{
user_id:
stranger
.
id
,
access_level:
Member
::
REPORTER
}
params:
{
user_id:
stranger
.
id
,
access_level:
Member
::
REPORTER
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
][
'access_level'
]).
to
eq
([
"should be greater than or equal to Developer inherited membership from group
#{
parent
.
name
}
"
])
expect
(
json_response
[
'message'
][
'access_level'
]).
to
eq
([
"should be greater than or equal to Developer inherited membership from group
#{
parent
.
name
}
"
])
end
end
...
@@ -279,7 +279,7 @@ describe API::Members do
...
@@ -279,7 +279,7 @@ describe API::Members do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
params:
{
user_id:
stranger
.
id
,
access_level:
Member
::
MAINTAINER
}
params:
{
user_id:
stranger
.
id
,
access_level:
Member
::
MAINTAINER
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'id'
]).
to
eq
(
stranger
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
stranger
.
id
)
expect
(
json_response
[
'access_level'
]).
to
eq
(
Member
::
MAINTAINER
)
expect
(
json_response
[
'access_level'
]).
to
eq
(
Member
::
MAINTAINER
)
end
end
...
@@ -289,14 +289,14 @@ describe API::Members do
...
@@ -289,14 +289,14 @@ describe API::Members do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
params:
{
user_id:
maintainer
.
id
,
access_level:
Member
::
MAINTAINER
}
params:
{
user_id:
maintainer
.
id
,
access_level:
Member
::
MAINTAINER
}
expect
(
response
).
to
have_gitlab_http_status
(
409
)
expect
(
response
).
to
have_gitlab_http_status
(
:conflict
)
end
end
it
'returns 404 when the user_id is not valid'
do
it
'returns 404 when the user_id is not valid'
do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
params:
{
user_id:
0
,
access_level:
Member
::
MAINTAINER
}
params:
{
user_id:
0
,
access_level:
Member
::
MAINTAINER
}
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
...
@@ -304,21 +304,21 @@ describe API::Members do
...
@@ -304,21 +304,21 @@ describe API::Members do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
params:
{
access_level:
Member
::
MAINTAINER
}
params:
{
access_level:
Member
::
MAINTAINER
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
'returns 400 when access_level is not given'
do
it
'returns 400 when access_level is not given'
do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
params:
{
user_id:
stranger
.
id
}
params:
{
user_id:
stranger
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
'returns 400 when access_level is not valid'
do
it
'returns 400 when access_level is not valid'
do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
params:
{
user_id:
stranger
.
id
,
access_level:
1234
}
params:
{
user_id:
stranger
.
id
,
access_level:
1234
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
end
end
...
@@ -340,7 +340,7 @@ describe API::Members do
...
@@ -340,7 +340,7 @@ describe API::Members do
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/
#{
developer
.
id
}
"
,
user
),
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/
#{
developer
.
id
}
"
,
user
),
params:
{
access_level:
Member
::
MAINTAINER
}
params:
{
access_level:
Member
::
MAINTAINER
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -351,7 +351,7 @@ describe API::Members do
...
@@ -351,7 +351,7 @@ describe API::Members do
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/
#{
developer
.
id
}
"
,
maintainer
),
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/
#{
developer
.
id
}
"
,
maintainer
),
params:
{
access_level:
Member
::
MAINTAINER
,
expires_at:
'2016-08-05'
}
params:
{
access_level:
Member
::
MAINTAINER
,
expires_at:
'2016-08-05'
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'id'
]).
to
eq
(
developer
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
developer
.
id
)
expect
(
json_response
[
'access_level'
]).
to
eq
(
Member
::
MAINTAINER
)
expect
(
json_response
[
'access_level'
]).
to
eq
(
Member
::
MAINTAINER
)
expect
(
json_response
[
'expires_at'
]).
to
eq
(
'2016-08-05'
)
expect
(
json_response
[
'expires_at'
]).
to
eq
(
'2016-08-05'
)
...
@@ -362,20 +362,20 @@ describe API::Members do
...
@@ -362,20 +362,20 @@ describe API::Members do
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/123"
,
maintainer
),
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/123"
,
maintainer
),
params:
{
access_level:
Member
::
MAINTAINER
}
params:
{
access_level:
Member
::
MAINTAINER
}
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
'returns 400 when access_level is not given'
do
it
'returns 400 when access_level is not given'
do
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/
#{
developer
.
id
}
"
,
maintainer
)
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/
#{
developer
.
id
}
"
,
maintainer
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
'returns 400 when access level is not valid'
do
it
'returns 400 when access level is not valid'
do
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/
#{
developer
.
id
}
"
,
maintainer
),
put
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/
#{
developer
.
id
}
"
,
maintainer
),
params:
{
access_level:
1234
}
params:
{
access_level:
1234
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
end
end
...
@@ -393,7 +393,7 @@ describe API::Members do
...
@@ -393,7 +393,7 @@ describe API::Members do
user
=
public_send
(
type
)
user
=
public_send
(
type
)
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/
#{
developer
.
id
}
"
,
user
)
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/
#{
developer
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -404,7 +404,7 @@ describe API::Members do
...
@@ -404,7 +404,7 @@ describe API::Members do
expect
do
expect
do
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/
#{
developer
.
id
}
"
,
developer
)
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/
#{
developer
.
id
}
"
,
developer
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
.
to
change
{
source
.
members
.
count
}.
by
(
-
1
)
end
.
to
change
{
source
.
members
.
count
}.
by
(
-
1
)
end
end
end
end
...
@@ -415,7 +415,7 @@ describe API::Members do
...
@@ -415,7 +415,7 @@ describe API::Members do
expect
do
expect
do
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/
#{
access_requester
.
id
}
"
,
maintainer
)
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/
#{
access_requester
.
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
...
@@ -424,7 +424,7 @@ describe API::Members do
...
@@ -424,7 +424,7 @@ describe API::Members do
expect
do
expect
do
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/
#{
developer
.
id
}
"
,
maintainer
)
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/
#{
developer
.
id
}
"
,
maintainer
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
.
to
change
{
source
.
members
.
count
}.
by
(
-
1
)
end
.
to
change
{
source
.
members
.
count
}.
by
(
-
1
)
end
end
...
@@ -436,7 +436,7 @@ describe API::Members do
...
@@ -436,7 +436,7 @@ describe API::Members do
it
'returns 404 if member does not exist'
do
it
'returns 404 if member does not exist'
do
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/123"
,
maintainer
)
delete
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members/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
...
@@ -491,7 +491,7 @@ describe API::Members do
...
@@ -491,7 +491,7 @@ describe API::Members do
post
api
(
"/projects/
#{
project
.
id
}
/members"
,
maintainer
),
post
api
(
"/projects/
#{
project
.
id
}
/members"
,
maintainer
),
params:
{
user_id:
stranger
.
id
,
access_level:
Member
::
OWNER
}
params:
{
user_id:
stranger
.
id
,
access_level:
Member
::
OWNER
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
.
to
change
{
project
.
members
.
count
}.
by
(
0
)
end
.
to
change
{
project
.
members
.
count
}.
by
(
0
)
end
end
end
end
...
...
spec/requests/api/merge_request_diffs_spec.rb
View file @
765fc43b
...
@@ -28,12 +28,12 @@ describe API::MergeRequestDiffs, 'MergeRequestDiffs' do
...
@@ -28,12 +28,12 @@ describe API::MergeRequestDiffs, 'MergeRequestDiffs' do
it
'returns a 404 when merge_request id is used instead of the iid'
do
it
'returns a 404 when merge_request id is used instead of the iid'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/versions"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/versions"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
'returns a 404 when merge_request_iid not found'
do
it
'returns a 404 when merge_request_iid not found'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/0/versions"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/0/versions"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -51,17 +51,17 @@ describe API::MergeRequestDiffs, 'MergeRequestDiffs' do
...
@@ -51,17 +51,17 @@ describe API::MergeRequestDiffs, 'MergeRequestDiffs' do
it
'returns a 404 when merge_request id is used instead of the iid'
do
it
'returns a 404 when merge_request id is used instead of the iid'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/versions/
#{
merge_request_diff
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/versions/
#{
merge_request_diff
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
'returns a 404 when merge_request version_id is not found'
do
it
'returns a 404 when merge_request version_id is not found'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/versions/0"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/versions/0"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
'returns a 404 when merge_request_iid is not found'
do
it
'returns a 404 when merge_request_iid is not found'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/12345/versions/
#{
merge_request_diff
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/12345/versions/
#{
merge_request_diff
.
id
}
"
,
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/merge_requests_spec.rb
View file @
765fc43b
...
@@ -194,7 +194,7 @@ describe API::MergeRequests do
...
@@ -194,7 +194,7 @@ describe API::MergeRequests do
it
'matches V4 response schema'
do
it
'matches V4 response schema'
do
get
api
(
endpoint_path
,
user
)
get
api
(
endpoint_path
,
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/merge_requests'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/merge_requests'
)
end
end
...
@@ -454,25 +454,25 @@ describe API::MergeRequests do
...
@@ -454,25 +454,25 @@ describe API::MergeRequests do
it
"returns authentication error without any scope"
do
it
"returns authentication error without any scope"
do
get
api
(
"/merge_requests"
)
get
api
(
"/merge_requests"
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
it
"returns authentication error when scope is assigned-to-me"
do
it
"returns authentication error when scope is assigned-to-me"
do
get
api
(
"/merge_requests"
),
params:
{
scope:
'assigned-to-me'
}
get
api
(
"/merge_requests"
),
params:
{
scope:
'assigned-to-me'
}
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
it
"returns authentication error when scope is assigned_to_me"
do
it
"returns authentication error when scope is assigned_to_me"
do
get
api
(
"/merge_requests"
),
params:
{
scope:
'assigned_to_me'
}
get
api
(
"/merge_requests"
),
params:
{
scope:
'assigned_to_me'
}
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
it
"returns authentication error when scope is created-by-me"
do
it
"returns authentication error when scope is created-by-me"
do
get
api
(
"/merge_requests"
),
params:
{
scope:
'created-by-me'
}
get
api
(
"/merge_requests"
),
params:
{
scope:
'created-by-me'
}
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
...
@@ -705,7 +705,7 @@ describe API::MergeRequests do
...
@@ -705,7 +705,7 @@ describe API::MergeRequests do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
"returns an array of no merge_requests when wip=yes"
do
it
"returns an array of no merge_requests when wip=yes"
do
...
@@ -818,7 +818,7 @@ describe API::MergeRequests do
...
@@ -818,7 +818,7 @@ describe API::MergeRequests do
merge_request
=
create
(
:merge_request
,
:with_test_reports
,
milestone:
milestone1
,
author:
user
,
assignees:
[
user
],
source_project:
project
,
target_project:
project
,
title:
"Test"
,
created_at:
base_time
)
merge_request
=
create
(
:merge_request
,
:with_test_reports
,
milestone:
milestone1
,
author:
user
,
assignees:
[
user
],
source_project:
project
,
target_project:
project
,
title:
"Test"
,
created_at:
base_time
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
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/merge_request'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/merge_request'
)
end
end
...
@@ -828,7 +828,7 @@ describe API::MergeRequests do
...
@@ -828,7 +828,7 @@ describe API::MergeRequests do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'id'
]).
to
eq
(
merge_request
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
merge_request
.
id
)
expect
(
json_response
[
'iid'
]).
to
eq
(
merge_request
.
iid
)
expect
(
json_response
[
'iid'
]).
to
eq
(
merge_request
.
iid
)
expect
(
json_response
[
'project_id'
]).
to
eq
(
merge_request
.
project
.
id
)
expect
(
json_response
[
'project_id'
]).
to
eq
(
merge_request
.
project
.
id
)
...
@@ -866,7 +866,7 @@ describe API::MergeRequests do
...
@@ -866,7 +866,7 @@ describe API::MergeRequests do
it
'exposes description and title html when render_html is true'
do
it
'exposes description and title html when render_html is true'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
render_html:
true
}
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
render_html:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
include
(
'title_html'
,
'description_html'
)
expect
(
json_response
).
to
include
(
'title_html'
,
'description_html'
)
end
end
...
@@ -874,7 +874,7 @@ describe API::MergeRequests do
...
@@ -874,7 +874,7 @@ describe API::MergeRequests do
it
'exposes rebase_in_progress when include_rebase_in_progress is true'
do
it
'exposes rebase_in_progress when include_rebase_in_progress is true'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
include_rebase_in_progress:
true
}
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
include_rebase_in_progress:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
include
(
'rebase_in_progress'
)
expect
(
json_response
).
to
include
(
'rebase_in_progress'
)
end
end
...
@@ -950,19 +950,19 @@ describe API::MergeRequests do
...
@@ -950,19 +950,19 @@ describe API::MergeRequests do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
include_diverged_commits_count:
true
}
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
include_diverged_commits_count:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'diverged_commits_count'
]).
to
eq
(
1
)
expect
(
json_response
[
'diverged_commits_count'
]).
to
eq
(
1
)
end
end
it
"returns a 404 error if merge_request_iid not found"
do
it
"returns a 404 error if merge_request_iid not found"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/0"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/0"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
"returns a 404 error if merge_request `id` is used instead of iid"
do
it
"returns a 404 error if merge_request `id` is used instead of iid"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
context
'Work in Progress'
do
context
'Work in Progress'
do
...
@@ -971,7 +971,7 @@ describe API::MergeRequests do
...
@@ -971,7 +971,7 @@ describe API::MergeRequests do
it
"returns merge request"
do
it
"returns merge request"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_wip
.
iid
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_wip
.
iid
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'work_in_progress'
]).
to
eq
(
true
)
expect
(
json_response
[
'work_in_progress'
]).
to
eq
(
true
)
end
end
end
end
...
@@ -990,7 +990,7 @@ describe API::MergeRequests do
...
@@ -990,7 +990,7 @@ describe API::MergeRequests do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_overflow
.
iid
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_overflow
.
iid
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'changes_count'
]).
to
eq
(
'5+'
)
expect
(
json_response
[
'changes_count'
]).
to
eq
(
'5+'
)
end
end
end
end
...
@@ -1059,13 +1059,13 @@ describe API::MergeRequests do
...
@@ -1059,13 +1059,13 @@ describe API::MergeRequests do
it
'returns a 404 when merge_request_iid not found'
do
it
'returns a 404 when merge_request_iid not found'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/0/commits"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/0/commits"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
'returns a 404 when merge_request id is used instead of iid'
do
it
'returns a 404 when merge_request id is used instead of iid'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/commits"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/commits"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -1083,7 +1083,7 @@ describe API::MergeRequests do
...
@@ -1083,7 +1083,7 @@ describe API::MergeRequests do
it
'returns a 404 when merge_request_iid not found'
do
it
'returns a 404 when merge_request_iid not found'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/0/context_commits"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/0/context_commits"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -1091,19 +1091,19 @@ describe API::MergeRequests do
...
@@ -1091,19 +1091,19 @@ describe API::MergeRequests do
it
'returns the change information of the merge_request'
do
it
'returns the change information of the merge_request'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/changes"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/changes"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'changes'
].
size
).
to
eq
(
merge_request
.
diffs
.
size
)
expect
(
json_response
[
'changes'
].
size
).
to
eq
(
merge_request
.
diffs
.
size
)
end
end
it
'returns a 404 when merge_request_iid not found'
do
it
'returns a 404 when merge_request_iid not found'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/0/changes"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/0/changes"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
'returns a 404 when merge_request id is used instead of iid'
do
it
'returns a 404 when merge_request id is used instead of iid'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/changes"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/changes"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -1123,14 +1123,14 @@ describe API::MergeRequests do
...
@@ -1123,14 +1123,14 @@ describe API::MergeRequests do
it
'exposes basic attributes'
do
it
'exposes basic attributes'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/pipelines"
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/pipelines"
)
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/pipelines'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/pipelines'
)
end
end
it
'returns 404 if MR does not exist'
do
it
'returns 404 if MR does not exist'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/777/pipelines"
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/777/pipelines"
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -1143,7 +1143,7 @@ describe API::MergeRequests do
...
@@ -1143,7 +1143,7 @@ describe API::MergeRequests do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/pipelines"
,
guest
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/pipelines"
,
guest
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
end
end
...
@@ -1186,7 +1186,7 @@ describe API::MergeRequests do
...
@@ -1186,7 +1186,7 @@ describe API::MergeRequests do
context
'when authorized'
do
context
'when authorized'
do
it
'creates and returns the new Pipeline'
do
it
'creates and returns the new Pipeline'
do
expect
{
request
}.
to
change
(
Ci
::
Pipeline
,
:count
).
by
(
1
)
expect
{
request
}.
to
change
(
Ci
::
Pipeline
,
:count
).
by
(
1
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
).
to
be_a
Hash
end
end
end
end
...
@@ -1196,7 +1196,7 @@ describe API::MergeRequests do
...
@@ -1196,7 +1196,7 @@ describe API::MergeRequests do
it
'responds with a blank 404'
do
it
'responds with a blank 404'
do
expect
{
request
}.
not_to
change
(
Ci
::
Pipeline
,
:count
)
expect
{
request
}.
not_to
change
(
Ci
::
Pipeline
,
:count
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -1205,7 +1205,7 @@ describe API::MergeRequests do
...
@@ -1205,7 +1205,7 @@ describe API::MergeRequests do
it
'responds with a blank 404'
do
it
'responds with a blank 404'
do
expect
{
request
}.
not_to
change
(
Ci
::
Pipeline
,
:count
)
expect
{
request
}.
not_to
change
(
Ci
::
Pipeline
,
:count
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
@@ -1225,7 +1225,7 @@ describe API::MergeRequests do
...
@@ -1225,7 +1225,7 @@ describe API::MergeRequests do
it
'creates a new merge request'
do
it
'creates a new merge request'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
params
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
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
(
'Test merge request'
)
expect
(
json_response
[
'title'
]).
to
eq
(
'Test merge request'
)
expect
(
json_response
[
'assignee'
][
'name'
]).
to
eq
(
user2
.
name
)
expect
(
json_response
[
'assignee'
][
'name'
]).
to
eq
(
user2
.
name
)
expect
(
json_response
[
'assignees'
].
first
[
'name'
]).
to
eq
(
user2
.
name
)
expect
(
json_response
[
'assignees'
].
first
[
'name'
]).
to
eq
(
user2
.
name
)
...
@@ -1236,7 +1236,7 @@ describe API::MergeRequests do
...
@@ -1236,7 +1236,7 @@ describe API::MergeRequests do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
params
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
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
(
'Test merge request'
)
expect
(
json_response
[
'title'
]).
to
eq
(
'Test merge request'
)
expect
(
json_response
[
'assignee'
]).
to
be_nil
expect
(
json_response
[
'assignee'
]).
to
be_nil
end
end
...
@@ -1249,7 +1249,7 @@ describe API::MergeRequests do
...
@@ -1249,7 +1249,7 @@ describe API::MergeRequests do
post
api
(
"/projects/
#{
private_project
.
id
}
/merge_requests"
,
user
),
params:
params
post
api
(
"/projects/
#{
private_project
.
id
}
/merge_requests"
,
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'assignee'
]).
to
be_nil
expect
(
json_response
[
'assignee'
]).
to
be_nil
end
end
end
end
...
@@ -1268,7 +1268,7 @@ describe API::MergeRequests do
...
@@ -1268,7 +1268,7 @@ describe API::MergeRequests do
it
'creates a new project merge request with no more than one assignee'
do
it
'creates a new project merge request with no more than one assignee'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
params
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
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
(
'Test merge request'
)
expect
(
json_response
[
'title'
]).
to
eq
(
'Test merge request'
)
expect
(
json_response
[
'assignees'
].
count
).
to
eq
(
1
)
expect
(
json_response
[
'assignees'
].
count
).
to
eq
(
1
)
expect
(
json_response
[
'assignees'
].
first
[
'name'
]).
to
eq
(
user
.
name
)
expect
(
json_response
[
'assignees'
].
first
[
'name'
]).
to
eq
(
user
.
name
)
...
@@ -1294,7 +1294,7 @@ describe API::MergeRequests do
...
@@ -1294,7 +1294,7 @@ describe API::MergeRequests do
params
[
:labels
]
=
labels
params
[
:labels
]
=
labels
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
params
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
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
(
'Test merge_request'
)
expect
(
json_response
[
'title'
]).
to
eq
(
'Test merge_request'
)
expect
(
json_response
[
'labels'
]).
to
eq
(
%w(label label2)
)
expect
(
json_response
[
'labels'
]).
to
eq
(
%w(label label2)
)
expect
(
json_response
[
'milestone'
][
'id'
]).
to
eq
(
milestone
.
id
)
expect
(
json_response
[
'milestone'
][
'id'
]).
to
eq
(
milestone
.
id
)
...
@@ -1319,7 +1319,7 @@ describe API::MergeRequests do
...
@@ -1319,7 +1319,7 @@ describe API::MergeRequests do
params
[
:labels
]
=
'label, label?, label&foo, ?, &'
params
[
:labels
]
=
'label, label?, label&foo, ?, &'
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
params
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'labels'
]).
to
include
'label'
expect
(
json_response
[
'labels'
]).
to
include
'label'
expect
(
json_response
[
'labels'
]).
to
include
'label?'
expect
(
json_response
[
'labels'
]).
to
include
'label?'
expect
(
json_response
[
'labels'
]).
to
include
'label&foo'
expect
(
json_response
[
'labels'
]).
to
include
'label&foo'
...
@@ -1331,7 +1331,7 @@ describe API::MergeRequests do
...
@@ -1331,7 +1331,7 @@ describe API::MergeRequests do
params
[
:labels
]
=
[
'label'
,
'label?'
,
'label&foo, ?, &'
,
'1, 2'
,
3
,
4
]
params
[
:labels
]
=
[
'label'
,
'label?'
,
'label&foo, ?, &'
,
'1, 2'
,
3
,
4
]
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
params
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'labels'
]).
to
include
'label'
expect
(
json_response
[
'labels'
]).
to
include
'label'
expect
(
json_response
[
'labels'
]).
to
include
'label?'
expect
(
json_response
[
'labels'
]).
to
include
'label?'
expect
(
json_response
[
'labels'
]).
to
include
'label&foo'
expect
(
json_response
[
'labels'
]).
to
include
'label&foo'
...
@@ -1347,7 +1347,7 @@ describe API::MergeRequests do
...
@@ -1347,7 +1347,7 @@ describe API::MergeRequests do
params
[
:labels
]
=
''
params
[
:labels
]
=
''
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
params
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'labels'
]).
to
eq
([])
expect
(
json_response
[
'labels'
]).
to
eq
([])
end
end
...
@@ -1357,7 +1357,7 @@ describe API::MergeRequests do
...
@@ -1357,7 +1357,7 @@ describe API::MergeRequests do
params:
params
.
to_json
,
params:
params
.
to_json
,
headers:
{
'Content-Type'
:
'application/json'
}
headers:
{
'Content-Type'
:
'application/json'
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'labels'
]).
to
eq
([])
expect
(
json_response
[
'labels'
]).
to
eq
([])
end
end
...
@@ -1365,7 +1365,7 @@ describe API::MergeRequests do
...
@@ -1365,7 +1365,7 @@ describe API::MergeRequests do
params
[
:labels
]
=
[]
params
[
:labels
]
=
[]
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
params
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'labels'
]).
to
eq
([])
expect
(
json_response
[
'labels'
]).
to
eq
([])
end
end
...
@@ -1373,7 +1373,7 @@ describe API::MergeRequests do
...
@@ -1373,7 +1373,7 @@ describe API::MergeRequests do
params
[
:labels
]
=
[
''
]
params
[
:labels
]
=
[
''
]
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
params
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'labels'
]).
to
eq
([])
expect
(
json_response
[
'labels'
]).
to
eq
([])
end
end
...
@@ -1381,7 +1381,7 @@ describe API::MergeRequests do
...
@@ -1381,7 +1381,7 @@ describe API::MergeRequests do
params
[
:labels
]
=
[
''
,
''
,
''
]
params
[
:labels
]
=
[
''
,
''
,
''
]
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
params
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'labels'
]).
to
eq
([])
expect
(
json_response
[
'labels'
]).
to
eq
([])
end
end
end
end
...
@@ -1389,25 +1389,25 @@ describe API::MergeRequests do
...
@@ -1389,25 +1389,25 @@ describe API::MergeRequests do
it
"returns 422 when source_branch equals target_branch"
do
it
"returns 422 when source_branch equals target_branch"
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
{
title:
"Test merge_request"
,
source_branch:
"master"
,
target_branch:
"master"
,
author:
user
}
params:
{
title:
"Test merge_request"
,
source_branch:
"master"
,
target_branch:
"master"
,
author:
user
}
expect
(
response
).
to
have_gitlab_http_status
(
422
)
expect
(
response
).
to
have_gitlab_http_status
(
:unprocessable_entity
)
end
end
it
"returns 400 when source_branch is missing"
do
it
"returns 400 when source_branch is missing"
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
{
title:
"Test merge_request"
,
target_branch:
"master"
,
author:
user
}
params:
{
title:
"Test merge_request"
,
target_branch:
"master"
,
author:
user
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
"returns 400 when target_branch is missing"
do
it
"returns 400 when target_branch is missing"
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
{
title:
"Test merge_request"
,
source_branch:
"markdown"
,
author:
user
}
params:
{
title:
"Test merge_request"
,
source_branch:
"markdown"
,
author:
user
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
"returns 400 when title is missing"
do
it
"returns 400 when title is missing"
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params:
{
target_branch:
'master'
,
source_branch:
'markdown'
}
params:
{
target_branch:
'master'
,
source_branch:
'markdown'
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
context
'with existing MR'
do
context
'with existing MR'
do
...
@@ -1432,7 +1432,7 @@ describe API::MergeRequests do
...
@@ -1432,7 +1432,7 @@ describe API::MergeRequests do
author:
user
author:
user
}
}
end
.
to
change
{
MergeRequest
.
count
}.
by
(
0
)
end
.
to
change
{
MergeRequest
.
count
}.
by
(
0
)
expect
(
response
).
to
have_gitlab_http_status
(
409
)
expect
(
response
).
to
have_gitlab_http_status
(
:conflict
)
end
end
end
end
...
@@ -1471,7 +1471,7 @@ describe API::MergeRequests do
...
@@ -1471,7 +1471,7 @@ describe API::MergeRequests do
it
"returns merge_request"
do
it
"returns merge_request"
do
post
api
(
"/projects/
#{
forked_project
.
id
}
/merge_requests"
,
user2
),
post
api
(
"/projects/
#{
forked_project
.
id
}
/merge_requests"
,
user2
),
params:
{
title:
'Test merge_request'
,
source_branch:
"feature_conflict"
,
target_branch:
"master"
,
author:
user2
,
target_project_id:
project
.
id
,
description:
'Test description for Test merge_request'
}
params:
{
title:
'Test merge_request'
,
source_branch:
"feature_conflict"
,
target_branch:
"master"
,
author:
user2
,
target_project_id:
project
.
id
,
description:
'Test description for Test merge_request'
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'title'
]).
to
eq
(
'Test merge_request'
)
expect
(
json_response
[
'title'
]).
to
eq
(
'Test merge_request'
)
expect
(
json_response
[
'description'
]).
to
eq
(
'Test description for Test merge_request'
)
expect
(
json_response
[
'description'
]).
to
eq
(
'Test description for Test merge_request'
)
end
end
...
@@ -1482,7 +1482,7 @@ describe API::MergeRequests do
...
@@ -1482,7 +1482,7 @@ describe API::MergeRequests do
expect
(
forked_project
.
forked_from_project
).
to
eq
(
project
)
expect
(
forked_project
.
forked_from_project
).
to
eq
(
project
)
post
api
(
"/projects/
#{
forked_project
.
id
}
/merge_requests"
,
user2
),
post
api
(
"/projects/
#{
forked_project
.
id
}
/merge_requests"
,
user2
),
params:
{
title:
'Test merge_request'
,
source_branch:
"master"
,
target_branch:
"master"
,
author:
user2
,
target_project_id:
project
.
id
}
params:
{
title:
'Test merge_request'
,
source_branch:
"master"
,
target_branch:
"master"
,
author:
user2
,
target_project_id:
project
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'title'
]).
to
eq
(
'Test merge_request'
)
expect
(
json_response
[
'title'
]).
to
eq
(
'Test merge_request'
)
end
end
...
@@ -1498,31 +1498,31 @@ describe API::MergeRequests do
...
@@ -1498,31 +1498,31 @@ describe API::MergeRequests do
target_project_id:
project
.
id
target_project_id:
project
.
id
}
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
it
"returns 400 when source_branch is missing"
do
it
"returns 400 when source_branch is missing"
do
post
api
(
"/projects/
#{
forked_project
.
id
}
/merge_requests"
,
user2
),
post
api
(
"/projects/
#{
forked_project
.
id
}
/merge_requests"
,
user2
),
params:
{
title:
'Test merge_request'
,
target_branch:
"master"
,
author:
user2
,
target_project_id:
project
.
id
}
params:
{
title:
'Test merge_request'
,
target_branch:
"master"
,
author:
user2
,
target_project_id:
project
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
"returns 400 when target_branch is missing"
do
it
"returns 400 when target_branch is missing"
do
post
api
(
"/projects/
#{
forked_project
.
id
}
/merge_requests"
,
user2
),
post
api
(
"/projects/
#{
forked_project
.
id
}
/merge_requests"
,
user2
),
params:
{
title:
'Test merge_request'
,
target_branch:
"master"
,
author:
user2
,
target_project_id:
project
.
id
}
params:
{
title:
'Test merge_request'
,
target_branch:
"master"
,
author:
user2
,
target_project_id:
project
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
"returns 400 when title is missing"
do
it
"returns 400 when title is missing"
do
post
api
(
"/projects/
#{
forked_project
.
id
}
/merge_requests"
,
user2
),
post
api
(
"/projects/
#{
forked_project
.
id
}
/merge_requests"
,
user2
),
params:
{
target_branch:
'master'
,
source_branch:
'markdown'
,
author:
user2
,
target_project_id:
project
.
id
}
params:
{
target_branch:
'master'
,
source_branch:
'markdown'
,
author:
user2
,
target_project_id:
project
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
'allows setting `allow_collaboration`'
,
:sidekiq_might_not_need_inline
do
it
'allows setting `allow_collaboration`'
,
:sidekiq_might_not_need_inline
do
post
api
(
"/projects/
#{
forked_project
.
id
}
/merge_requests"
,
user2
),
post
api
(
"/projects/
#{
forked_project
.
id
}
/merge_requests"
,
user2
),
params:
{
title:
'Test merge_request'
,
source_branch:
"feature_conflict"
,
target_branch:
"master"
,
author:
user2
,
target_project_id:
project
.
id
,
allow_collaboration:
true
}
params:
{
title:
'Test merge_request'
,
source_branch:
"feature_conflict"
,
target_branch:
"master"
,
author:
user2
,
target_project_id:
project
.
id
,
allow_collaboration:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'allow_collaboration'
]).
to
be_truthy
expect
(
json_response
[
'allow_collaboration'
]).
to
be_truthy
expect
(
json_response
[
'allow_maintainer_to_push'
]).
to
be_truthy
expect
(
json_response
[
'allow_maintainer_to_push'
]).
to
be_truthy
end
end
...
@@ -1541,20 +1541,20 @@ describe API::MergeRequests do
...
@@ -1541,20 +1541,20 @@ describe API::MergeRequests do
post
api
(
"/projects/
#{
forked_project
.
id
}
/merge_requests"
,
user2
),
params:
params
post
api
(
"/projects/
#{
forked_project
.
id
}
/merge_requests"
,
user2
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
422
)
expect
(
response
).
to
have_gitlab_http_status
(
:unprocessable_entity
)
end
end
it
'returns 403 if targeting a different fork which user can not access'
do
it
'returns 403 if targeting a different fork which user can not access'
do
post
api
(
"/projects/
#{
forked_project
.
id
}
/merge_requests"
,
user2
),
params:
params
post
api
(
"/projects/
#{
forked_project
.
id
}
/merge_requests"
,
user2
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
it
"returns 201 when target_branch is specified and for the same project"
,
:sidekiq_might_not_need_inline
do
it
"returns 201 when target_branch is specified and for the same project"
,
:sidekiq_might_not_need_inline
do
post
api
(
"/projects/
#{
forked_project
.
id
}
/merge_requests"
,
user2
),
post
api
(
"/projects/
#{
forked_project
.
id
}
/merge_requests"
,
user2
),
params:
{
title:
'Test merge_request'
,
target_branch:
'master'
,
source_branch:
'markdown'
,
author:
user2
,
target_project_id:
forked_project
.
id
}
params:
{
title:
'Test merge_request'
,
target_branch:
'master'
,
source_branch:
'markdown'
,
author:
user2
,
target_project_id:
forked_project
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
end
end
end
end
end
end
...
@@ -1585,7 +1585,7 @@ describe API::MergeRequests do
...
@@ -1585,7 +1585,7 @@ describe API::MergeRequests do
describe
'when authenticated'
do
describe
'when authenticated'
do
it
'creates and returns the new context commit'
do
it
'creates and returns the new context commit'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
,
authenticated_user
),
params:
params
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
,
authenticated_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'short_id'
]).
to
eq
(
commit
.
short_id
)
expect
(
json_response
.
first
[
'short_id'
]).
to
eq
(
commit
.
short_id
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
commit
.
title
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
commit
.
title
)
...
@@ -1602,46 +1602,46 @@ describe API::MergeRequests do
...
@@ -1602,46 +1602,46 @@ describe API::MergeRequests do
end
end
it
'returns 400 when the context commit is already created'
do
it
'returns 400 when the context commit is already created'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
,
authenticated_user
),
params:
params
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
,
authenticated_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
(
"Context commits: [
\"
#{
commit
.
id
}
\"
] are already created"
)
expect
(
json_response
[
'message'
]).
to
eq
(
"Context commits: [
\"
#{
commit
.
id
}
\"
] are already created"
)
end
end
end
end
it
'returns 400 when one or more shas are invalid'
do
it
'returns 400 when one or more shas are invalid'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
,
authenticated_user
),
params:
params_invalid_shas
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
,
authenticated_user
),
params:
params_invalid_shas
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
]).
to
eq
(
'One or more context commits\' sha is not valid.'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'One or more context commits\' sha is not valid.'
)
end
end
it
'returns 400 when the commits are empty'
do
it
'returns 400 when the commits are empty'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
,
authenticated_user
),
params:
params_empty_commits
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
,
authenticated_user
),
params:
params_empty_commits
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
'returns 400 when params is empty'
do
it
'returns 400 when params is empty'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
,
authenticated_user
)
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
,
authenticated_user
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
'returns 403 when creating new context commit for guest role'
do
it
'returns 403 when creating new context commit for guest role'
do
guest
=
create
(
:user
)
guest
=
create
(
:user
)
project
.
add_guest
(
guest
)
project
.
add_guest
(
guest
)
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
,
guest
),
params:
params
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
,
guest
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
it
'returns 403 when creating new context commit for reporter role'
do
it
'returns 403 when creating new context commit for reporter role'
do
reporter
=
create
(
:user
)
reporter
=
create
(
:user
)
project
.
add_reporter
(
reporter
)
project
.
add_reporter
(
reporter
)
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
,
reporter
),
params:
params
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
,
reporter
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
context
'when unauthenticated'
do
context
'when unauthenticated'
do
it
'returns 401 if user tries to create context commits'
do
it
'returns 401 if user tries to create context commits'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
),
params:
params
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
end
end
...
@@ -1656,7 +1656,7 @@ describe API::MergeRequests do
...
@@ -1656,7 +1656,7 @@ describe API::MergeRequests do
it
"denies the deletion of the merge request"
do
it
"denies the deletion of the merge request"
do
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
developer
)
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
developer
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -1664,19 +1664,19 @@ describe API::MergeRequests do
...
@@ -1664,19 +1664,19 @@ describe API::MergeRequests do
it
"destroys the merge request owners can destroy"
do
it
"destroys the merge request owners can destroy"
do
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
end
it
"returns 404 for an invalid merge request IID"
do
it
"returns 404 for an invalid merge request IID"
do
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/12345"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/12345"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
"returns 404 if the merge request id is used instead of iid"
do
it
"returns 404 if the merge request id is used instead of iid"
do
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
"
,
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
...
@@ -1712,40 +1712,40 @@ describe API::MergeRequests do
...
@@ -1712,40 +1712,40 @@ describe API::MergeRequests do
it
"deletes context commit"
do
it
"deletes context commit"
do
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/context_commits"
,
authenticated_user
),
params:
params
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/context_commits"
,
authenticated_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
end
it
"returns 400 when invalid commit sha is passed"
do
it
"returns 400 when invalid commit sha is passed"
do
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/context_commits"
,
authenticated_user
),
params:
params_invalid_shas
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/context_commits"
,
authenticated_user
),
params:
params_invalid_shas
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
"message"
]).
to
eq
(
'One or more context commits\' sha is not valid.'
)
expect
(
json_response
[
"message"
]).
to
eq
(
'One or more context commits\' sha is not valid.'
)
end
end
it
"returns 400 when commits is empty"
do
it
"returns 400 when commits is empty"
do
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/context_commits"
,
authenticated_user
),
params:
params_empty_commits
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/context_commits"
,
authenticated_user
),
params:
params_empty_commits
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
"returns 400 when no params is passed"
do
it
"returns 400 when no params is passed"
do
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/context_commits"
,
authenticated_user
)
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/context_commits"
,
authenticated_user
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
'returns 403 when deleting existing context commit for guest role'
do
it
'returns 403 when deleting existing context commit for guest role'
do
guest
=
create
(
:user
)
guest
=
create
(
:user
)
project
.
add_guest
(
guest
)
project
.
add_guest
(
guest
)
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
,
guest
),
params:
params
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
,
guest
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
it
'returns 403 when deleting existing context commit for reporter role'
do
it
'returns 403 when deleting existing context commit for reporter role'
do
reporter
=
create
(
:user
)
reporter
=
create
(
:user
)
project
.
add_reporter
(
reporter
)
project
.
add_reporter
(
reporter
)
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
,
reporter
),
params:
params
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_iid
}
/context_commits"
,
reporter
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -1753,7 +1753,7 @@ describe API::MergeRequests do
...
@@ -1753,7 +1753,7 @@ describe API::MergeRequests do
it
"returns 401, unauthorised error"
do
it
"returns 401, unauthorised error"
do
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/context_commits"
)
delete
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/context_commits"
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
end
end
...
@@ -1764,7 +1764,7 @@ describe API::MergeRequests do
...
@@ -1764,7 +1764,7 @@ describe API::MergeRequests do
it
"returns merge_request in case of success"
do
it
"returns merge_request in case of success"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
"returns 406 if branch can't be merged"
do
it
"returns 406 if branch can't be merged"
do
...
@@ -1773,21 +1773,21 @@ describe API::MergeRequests do
...
@@ -1773,21 +1773,21 @@ describe API::MergeRequests do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
406
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_acceptable
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Branch cannot be merged'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Branch cannot be merged'
)
end
end
it
"returns 405 if merge_request is not open"
do
it
"returns 405 if merge_request is not open"
do
merge_request
.
close
merge_request
.
close
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
405
)
expect
(
response
).
to
have_gitlab_http_status
(
:method_not_allowed
)
expect
(
json_response
[
'message'
]).
to
eq
(
'405 Method Not Allowed'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'405 Method Not Allowed'
)
end
end
it
"returns 405 if merge_request is a work in progress"
do
it
"returns 405 if merge_request is a work in progress"
do
merge_request
.
update_attribute
(
:title
,
"WIP:
#{
merge_request
.
title
}
"
)
merge_request
.
update_attribute
(
:title
,
"WIP:
#{
merge_request
.
title
}
"
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
405
)
expect
(
response
).
to
have_gitlab_http_status
(
:method_not_allowed
)
expect
(
json_response
[
'message'
]).
to
eq
(
'405 Method Not Allowed'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'405 Method Not Allowed'
)
end
end
...
@@ -1801,7 +1801,7 @@ describe API::MergeRequests do
...
@@ -1801,7 +1801,7 @@ describe API::MergeRequests do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
405
)
expect
(
response
).
to
have_gitlab_http_status
(
:method_not_allowed
)
expect
(
json_response
[
'message'
]).
to
eq
(
'405 Method Not Allowed'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'405 Method Not Allowed'
)
end
end
...
@@ -1809,21 +1809,21 @@ describe API::MergeRequests do
...
@@ -1809,21 +1809,21 @@ describe API::MergeRequests do
user2
=
create
(
:user
)
user2
=
create
(
:user
)
project
.
add_reporter
(
user2
)
project
.
add_reporter
(
user2
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user2
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user2
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
expect
(
json_response
[
'message'
]).
to
eq
(
'401 Unauthorized'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'401 Unauthorized'
)
end
end
it
"returns 409 if the SHA parameter doesn't match"
do
it
"returns 409 if the SHA parameter doesn't match"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
),
params:
{
sha:
merge_request
.
diff_head_sha
.
reverse
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
),
params:
{
sha:
merge_request
.
diff_head_sha
.
reverse
}
expect
(
response
).
to
have_gitlab_http_status
(
409
)
expect
(
response
).
to
have_gitlab_http_status
(
:conflict
)
expect
(
json_response
[
'message'
]).
to
start_with
(
'SHA does not match HEAD of source branch'
)
expect
(
json_response
[
'message'
]).
to
start_with
(
'SHA does not match HEAD of source branch'
)
end
end
it
"succeeds if the SHA parameter matches"
do
it
"succeeds if the SHA parameter matches"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
),
params:
{
sha:
merge_request
.
diff_head_sha
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
),
params:
{
sha:
merge_request
.
diff_head_sha
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
"updates the MR's squash attribute"
do
it
"updates the MR's squash attribute"
do
...
@@ -1831,7 +1831,7 @@ describe API::MergeRequests do
...
@@ -1831,7 +1831,7 @@ describe API::MergeRequests do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
),
params:
{
squash:
true
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
),
params:
{
squash:
true
}
end
.
to
change
{
merge_request
.
reload
.
squash
}
end
.
to
change
{
merge_request
.
reload
.
squash
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'does not merge if merge_when_pipeline_succeeds is passed and the pipeline has failed'
do
it
'does not merge if merge_when_pipeline_succeeds is passed and the pipeline has failed'
do
...
@@ -1842,7 +1842,7 @@ describe API::MergeRequests do
...
@@ -1842,7 +1842,7 @@ describe API::MergeRequests do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
),
params:
{
merge_when_pipeline_succeeds:
true
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
),
params:
{
merge_when_pipeline_succeeds:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
405
)
expect
(
response
).
to
have_gitlab_http_status
(
:method_not_allowed
)
expect
(
merge_request
.
reload
.
state
).
to
eq
(
'opened'
)
expect
(
merge_request
.
reload
.
state
).
to
eq
(
'opened'
)
end
end
...
@@ -1851,7 +1851,7 @@ describe API::MergeRequests do
...
@@ -1851,7 +1851,7 @@ describe API::MergeRequests do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
),
params:
{
merge_when_pipeline_succeeds:
true
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
),
params:
{
merge_when_pipeline_succeeds:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'state'
]).
to
eq
(
'merged'
)
expect
(
json_response
[
'state'
]).
to
eq
(
'merged'
)
end
end
...
@@ -1861,7 +1861,7 @@ describe API::MergeRequests do
...
@@ -1861,7 +1861,7 @@ describe API::MergeRequests do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
),
params:
{
merge_when_pipeline_succeeds:
true
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
),
params:
{
merge_when_pipeline_succeeds:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'title'
]).
to
eq
(
'Test'
)
expect
(
json_response
[
'title'
]).
to
eq
(
'Test'
)
expect
(
json_response
[
'merge_when_pipeline_succeeds'
]).
to
eq
(
true
)
expect
(
json_response
[
'merge_when_pipeline_succeeds'
]).
to
eq
(
true
)
end
end
...
@@ -1873,7 +1873,7 @@ describe API::MergeRequests do
...
@@ -1873,7 +1873,7 @@ describe API::MergeRequests do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
),
params:
{
merge_when_pipeline_succeeds:
true
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
),
params:
{
merge_when_pipeline_succeeds:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'title'
]).
to
eq
(
'Test'
)
expect
(
json_response
[
'title'
]).
to
eq
(
'Test'
)
expect
(
json_response
[
'merge_when_pipeline_succeeds'
]).
to
eq
(
true
)
expect
(
json_response
[
'merge_when_pipeline_succeeds'
]).
to
eq
(
true
)
end
end
...
@@ -1881,13 +1881,13 @@ describe API::MergeRequests do
...
@@ -1881,13 +1881,13 @@ describe API::MergeRequests do
it
"returns 404 for an invalid merge request IID"
do
it
"returns 404 for an invalid merge request IID"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/12345/merge"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/12345/merge"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
"returns 404 if the merge request id is used instead of iid"
do
it
"returns 404 if the merge request id is used instead of iid"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/merge"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/merge"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
describe
"the squash_commit_message param"
do
describe
"the squash_commit_message param"
do
...
@@ -1923,7 +1923,7 @@ describe API::MergeRequests do
...
@@ -1923,7 +1923,7 @@ describe API::MergeRequests do
params:
{
should_remove_source_branch:
true
}
params:
{
should_remove_source_branch:
true
}
)
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
source_repository
.
branch_exists?
(
source_branch
)).
to
be_falsy
expect
(
source_repository
.
branch_exists?
(
source_branch
)).
to
be_falsy
end
end
end
end
...
@@ -1938,7 +1938,7 @@ describe API::MergeRequests do
...
@@ -1938,7 +1938,7 @@ describe API::MergeRequests do
it
"records the squash commit SHA and returns it in the response"
do
it
"records the squash commit SHA and returns it in the response"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'squash_commit_sha'
].
length
).
to
eq
(
40
)
expect
(
json_response
[
'squash_commit_sha'
].
length
).
to
eq
(
40
)
end
end
end
end
...
@@ -1958,7 +1958,7 @@ describe API::MergeRequests do
...
@@ -1958,7 +1958,7 @@ describe API::MergeRequests do
it
'returns the generated ID from the merge service in case of success'
do
it
'returns the generated ID from the merge service in case of success'
do
get
api
(
url
,
user
)
get
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'commit_id'
]).
to
eq
(
merge_request
.
merge_ref_head
.
sha
)
expect
(
json_response
[
'commit_id'
]).
to
eq
(
merge_request
.
merge_ref_head
.
sha
)
end
end
...
@@ -1970,7 +1970,7 @@ describe API::MergeRequests do
...
@@ -1970,7 +1970,7 @@ describe API::MergeRequests do
it
'returns 200 if MR can be merged'
do
it
'returns 200 if MR can be merged'
do
get
api
(
url
,
user
)
get
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'commit_id'
]).
to
eq
(
merge_request
.
merge_ref_head
.
sha
)
expect
(
json_response
[
'commit_id'
]).
to
eq
(
merge_request
.
merge_ref_head
.
sha
)
end
end
...
@@ -1981,7 +1981,7 @@ describe API::MergeRequests do
...
@@ -1981,7 +1981,7 @@ describe API::MergeRequests do
get
api
(
url
,
user
)
get
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Merge request is not mergeable'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Merge request is not mergeable'
)
end
end
end
end
...
@@ -1995,7 +1995,7 @@ describe API::MergeRequests do
...
@@ -1995,7 +1995,7 @@ describe API::MergeRequests 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
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
end
end
end
end
...
@@ -2006,7 +2006,7 @@ describe API::MergeRequests do
...
@@ -2006,7 +2006,7 @@ describe API::MergeRequests do
it
'returns 404'
do
it
'returns 404'
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
...
@@ -2016,7 +2016,7 @@ describe API::MergeRequests do
...
@@ -2016,7 +2016,7 @@ describe API::MergeRequests do
it
'returns 404'
do
it
'returns 404'
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
end
end
...
@@ -2030,7 +2030,7 @@ describe API::MergeRequests do
...
@@ -2030,7 +2030,7 @@ describe API::MergeRequests do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
state_event:
"close"
,
remove_source_branch:
false
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
state_event:
"close"
,
remove_source_branch:
false
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'state'
]).
to
eq
(
'closed'
)
expect
(
json_response
[
'state'
]).
to
eq
(
'closed'
)
expect
(
json_response
[
'force_remove_source_branch'
]).
to
be_falsey
expect
(
json_response
[
'force_remove_source_branch'
]).
to
be_falsey
end
end
...
@@ -2042,7 +2042,7 @@ describe API::MergeRequests do
...
@@ -2042,7 +2042,7 @@ describe API::MergeRequests do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
state_event:
"close"
,
remove_source_branch:
true
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
state_event:
"close"
,
remove_source_branch:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'state'
]).
to
eq
(
'closed'
)
expect
(
json_response
[
'state'
]).
to
eq
(
'closed'
)
expect
(
json_response
[
'force_remove_source_branch'
]).
to
be_truthy
expect
(
json_response
[
'force_remove_source_branch'
]).
to
be_truthy
end
end
...
@@ -2063,7 +2063,7 @@ describe API::MergeRequests do
...
@@ -2063,7 +2063,7 @@ describe API::MergeRequests do
it
'is true for an authorized user'
do
it
'is true for an authorized user'
do
put
api
(
"/projects/
#{
target_project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
fork_owner
),
params:
{
state_event:
'close'
,
remove_source_branch:
true
}
put
api
(
"/projects/
#{
target_project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
fork_owner
),
params:
{
state_event:
'close'
,
remove_source_branch:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'state'
]).
to
eq
(
'closed'
)
expect
(
json_response
[
'state'
]).
to
eq
(
'closed'
)
expect
(
json_response
[
'force_remove_source_branch'
]).
to
be
true
expect
(
json_response
[
'force_remove_source_branch'
]).
to
be
true
end
end
...
@@ -2073,7 +2073,7 @@ describe API::MergeRequests do
...
@@ -2073,7 +2073,7 @@ describe API::MergeRequests do
put
api
(
"/projects/
#{
target_project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
target_project
.
owner
),
params:
{
state_event:
'close'
,
remove_source_branch:
true
}
put
api
(
"/projects/
#{
target_project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
target_project
.
owner
),
params:
{
state_event:
'close'
,
remove_source_branch:
true
}
end
.
not_to
change
{
merge_request
.
reload
.
merge_params
}
end
.
not_to
change
{
merge_request
.
reload
.
merge_params
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'state'
]).
to
eq
(
'closed'
)
expect
(
json_response
[
'state'
]).
to
eq
(
'closed'
)
expect
(
json_response
[
'force_remove_source_branch'
]).
to
be
false
expect
(
json_response
[
'force_remove_source_branch'
]).
to
be
false
end
end
...
@@ -2084,46 +2084,46 @@ describe API::MergeRequests do
...
@@ -2084,46 +2084,46 @@ describe API::MergeRequests do
it
"returns merge_request"
do
it
"returns merge_request"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
state_event:
"close"
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
state_event:
"close"
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'state'
]).
to
eq
(
'closed'
)
expect
(
json_response
[
'state'
]).
to
eq
(
'closed'
)
end
end
end
end
it
"updates title and returns merge_request"
do
it
"updates title and returns merge_request"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
title:
"New title"
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
title:
"New title"
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'title'
]).
to
eq
(
'New title'
)
expect
(
json_response
[
'title'
]).
to
eq
(
'New title'
)
end
end
it
"updates description and returns merge_request"
do
it
"updates description and returns merge_request"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
description:
"New description"
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
description:
"New description"
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'description'
]).
to
eq
(
'New description'
)
expect
(
json_response
[
'description'
]).
to
eq
(
'New description'
)
end
end
it
"updates milestone_id and returns merge_request"
do
it
"updates milestone_id and returns merge_request"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
milestone_id:
milestone
.
id
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
milestone_id:
milestone
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'milestone'
][
'id'
]).
to
eq
(
milestone
.
id
)
expect
(
json_response
[
'milestone'
][
'id'
]).
to
eq
(
milestone
.
id
)
end
end
it
"updates squash and returns merge_request"
do
it
"updates squash and returns merge_request"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
squash:
true
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
squash:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'squash'
]).
to
be_truthy
expect
(
json_response
[
'squash'
]).
to
be_truthy
end
end
it
"returns merge_request with renamed target_branch"
do
it
"returns merge_request with renamed target_branch"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
target_branch:
"wiki"
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
target_branch:
"wiki"
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'target_branch'
]).
to
eq
(
'wiki'
)
expect
(
json_response
[
'target_branch'
]).
to
eq
(
'wiki'
)
end
end
it
"returns merge_request that removes the source branch"
do
it
"returns merge_request that removes the source branch"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
remove_source_branch:
true
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
remove_source_branch:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'force_remove_source_branch'
]).
to
be_truthy
expect
(
json_response
[
'force_remove_source_branch'
]).
to
be_truthy
end
end
...
@@ -2136,7 +2136,7 @@ describe API::MergeRequests do
...
@@ -2136,7 +2136,7 @@ describe API::MergeRequests do
put
api
(
"/projects/
#{
private_project
.
id
}
/merge_requests/
#{
mr
.
iid
}
"
,
user
),
params:
params
put
api
(
"/projects/
#{
private_project
.
id
}
/merge_requests/
#{
mr
.
iid
}
"
,
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'assignee'
]).
to
be_nil
expect
(
json_response
[
'assignee'
]).
to
be_nil
end
end
...
@@ -2236,7 +2236,7 @@ describe API::MergeRequests do
...
@@ -2236,7 +2236,7 @@ describe API::MergeRequests do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
state_event:
'close'
,
title:
nil
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
state_event:
'close'
,
title:
nil
}
merge_request
.
reload
merge_request
.
reload
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
merge_request
.
state
).
to
eq
(
'opened'
)
expect
(
merge_request
.
state
).
to
eq
(
'opened'
)
end
end
...
@@ -2244,20 +2244,20 @@ describe API::MergeRequests do
...
@@ -2244,20 +2244,20 @@ describe API::MergeRequests do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
state_event:
'close'
,
target_branch:
nil
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
params:
{
state_event:
'close'
,
target_branch:
nil
}
merge_request
.
reload
merge_request
.
reload
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
merge_request
.
state
).
to
eq
(
'opened'
)
expect
(
merge_request
.
state
).
to
eq
(
'opened'
)
end
end
it
"returns 404 for an invalid merge request IID"
do
it
"returns 404 for an invalid merge request IID"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/12345"
,
user
),
params:
{
state_event:
"close"
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/12345"
,
user
),
params:
{
state_event:
"close"
}
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
"returns 404 if the merge request id is used instead of iid"
do
it
"returns 404 if the merge request id is used instead of iid"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
"
,
user
),
params:
{
state_event:
"close"
}
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
"
,
user
),
params:
{
state_event:
"close"
}
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -2310,19 +2310,19 @@ describe API::MergeRequests do
...
@@ -2310,19 +2310,19 @@ describe API::MergeRequests do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/closes_issues"
,
guest
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/closes_issues"
,
guest
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
it
"returns 404 for an invalid merge request IID"
do
it
"returns 404 for an invalid merge request IID"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/12345/closes_issues"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/12345/closes_issues"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
"returns 404 if the merge request id is used instead of iid"
do
it
"returns 404 if the merge request id is used instead of iid"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/closes_issues"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/closes_issues"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -2330,26 +2330,26 @@ describe API::MergeRequests do
...
@@ -2330,26 +2330,26 @@ describe API::MergeRequests do
it
'subscribes to a merge request'
do
it
'subscribes to a merge request'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/subscribe"
,
admin
)
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/subscribe"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'subscribed'
]).
to
eq
(
true
)
expect
(
json_response
[
'subscribed'
]).
to
eq
(
true
)
end
end
it
'returns 304 if already subscribed'
do
it
'returns 304 if already subscribed'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/subscribe"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/subscribe"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
304
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_modified
)
end
end
it
'returns 404 if the merge request is not found'
do
it
'returns 404 if the merge request is not found'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/123/subscribe"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/123/subscribe"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
'returns 404 if the merge request id is used instead of iid'
do
it
'returns 404 if the merge request id is used instead of iid'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/subscribe"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/subscribe"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
'returns 403 if user has no access to read code'
do
it
'returns 403 if user has no access to read code'
do
...
@@ -2358,7 +2358,7 @@ describe API::MergeRequests do
...
@@ -2358,7 +2358,7 @@ describe API::MergeRequests do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/subscribe"
,
guest
)
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/subscribe"
,
guest
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -2366,26 +2366,26 @@ describe API::MergeRequests do
...
@@ -2366,26 +2366,26 @@ describe API::MergeRequests do
it
'unsubscribes from a merge request'
do
it
'unsubscribes from a merge request'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/unsubscribe"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/unsubscribe"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'subscribed'
]).
to
eq
(
false
)
expect
(
json_response
[
'subscribed'
]).
to
eq
(
false
)
end
end
it
'returns 304 if not subscribed'
do
it
'returns 304 if not subscribed'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/unsubscribe"
,
admin
)
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/unsubscribe"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
304
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_modified
)
end
end
it
'returns 404 if the merge request is not found'
do
it
'returns 404 if the merge request is not found'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/123/unsubscribe"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/123/unsubscribe"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
'returns 404 if the merge request id is used instead of iid'
do
it
'returns 404 if the merge request id is used instead of iid'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/unsubscribe"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/unsubscribe"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
'returns 403 if user has no access to read code'
do
it
'returns 403 if user has no access to read code'
do
...
@@ -2394,7 +2394,7 @@ describe API::MergeRequests do
...
@@ -2394,7 +2394,7 @@ describe API::MergeRequests do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/unsubscribe"
,
guest
)
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/unsubscribe"
,
guest
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
end
...
@@ -2406,19 +2406,19 @@ describe API::MergeRequests do
...
@@ -2406,19 +2406,19 @@ describe API::MergeRequests do
it
'removes the merge_when_pipeline_succeeds status'
do
it
'removes the merge_when_pipeline_succeeds status'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/cancel_merge_when_pipeline_succeeds"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/cancel_merge_when_pipeline_succeeds"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
end
end
it
'returns 404 if the merge request is not found'
do
it
'returns 404 if the merge request is not found'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/123/cancel_merge_when_pipeline_succeeds"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/123/cancel_merge_when_pipeline_succeeds"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
'returns 404 if the merge request id is used instead of iid'
do
it
'returns 404 if the merge request id is used instead of iid'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/cancel_merge_when_pipeline_succeeds"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/cancel_merge_when_pipeline_succeeds"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -2431,7 +2431,7 @@ describe API::MergeRequests do
...
@@ -2431,7 +2431,7 @@ describe API::MergeRequests do
end
.
to
change
{
RebaseWorker
.
jobs
.
size
}.
by
(
1
)
end
.
to
change
{
RebaseWorker
.
jobs
.
size
}.
by
(
1
)
end
end
expect
(
response
).
to
have_gitlab_http_status
(
202
)
expect
(
response
).
to
have_gitlab_http_status
(
:accepted
)
expect
(
merge_request
.
reload
).
to
be_rebase_in_progress
expect
(
merge_request
.
reload
).
to
be_rebase_in_progress
expect
(
json_response
[
'rebase_in_progress'
]).
to
be
(
true
)
expect
(
json_response
[
'rebase_in_progress'
]).
to
be
(
true
)
end
end
...
@@ -2446,7 +2446,7 @@ describe API::MergeRequests do
...
@@ -2446,7 +2446,7 @@ describe API::MergeRequests do
end
.
to
change
{
RebaseWorker
.
jobs
.
size
}.
by
(
1
)
end
.
to
change
{
RebaseWorker
.
jobs
.
size
}.
by
(
1
)
end
end
expect
(
response
).
to
have_gitlab_http_status
(
202
)
expect
(
response
).
to
have_gitlab_http_status
(
:accepted
)
expect
(
merge_request
.
reload
).
to
be_rebase_in_progress
expect
(
merge_request
.
reload
).
to
be_rebase_in_progress
expect
(
json_response
[
'rebase_in_progress'
]).
to
be
(
true
)
expect
(
json_response
[
'rebase_in_progress'
]).
to
be
(
true
)
end
end
...
@@ -2459,7 +2459,7 @@ describe API::MergeRequests do
...
@@ -2459,7 +2459,7 @@ describe API::MergeRequests do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/rebase"
,
guest
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/rebase"
,
guest
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
it
'returns 409 if a rebase is already in progress'
do
it
'returns 409 if a rebase is already in progress'
do
...
@@ -2469,7 +2469,7 @@ describe API::MergeRequests do
...
@@ -2469,7 +2469,7 @@ describe API::MergeRequests do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/rebase"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/rebase"
,
user
)
end
end
expect
(
response
).
to
have_gitlab_http_status
(
409
)
expect
(
response
).
to
have_gitlab_http_status
(
:conflict
)
end
end
it
"returns 409 if rebase can't lock the row"
do
it
"returns 409 if rebase can't lock the row"
do
...
@@ -2478,7 +2478,7 @@ describe API::MergeRequests do
...
@@ -2478,7 +2478,7 @@ describe API::MergeRequests do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/rebase"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/rebase"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
409
)
expect
(
response
).
to
have_gitlab_http_status
(
:conflict
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Failed to enqueue the rebase operation, possibly due to a long-lived transaction. Try again later.'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Failed to enqueue the rebase operation, possibly due to a long-lived transaction. Try again later.'
)
end
end
end
end
...
...
spec/requests/api/namespaces_spec.rb
View file @
765fc43b
...
@@ -12,7 +12,7 @@ describe API::Namespaces do
...
@@ -12,7 +12,7 @@ describe API::Namespaces do
context
"when unauthenticated"
do
context
"when unauthenticated"
do
it
"returns authentication error"
do
it
"returns authentication error"
do
get
api
(
"/namespaces"
)
get
api
(
"/namespaces"
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
...
@@ -23,7 +23,7 @@ describe API::Namespaces do
...
@@ -23,7 +23,7 @@ describe API::Namespaces do
group_kind_json_response
=
json_response
.
find
{
|
resource
|
resource
[
'kind'
]
==
'group'
}
group_kind_json_response
=
json_response
.
find
{
|
resource
|
resource
[
'kind'
]
==
'group'
}
user_kind_json_response
=
json_response
.
find
{
|
resource
|
resource
[
'kind'
]
==
'user'
}
user_kind_json_response
=
json_response
.
find
{
|
resource
|
resource
[
'kind'
]
==
'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
(
group_kind_json_response
.
keys
).
to
include
(
'id'
,
'kind'
,
'name'
,
'path'
,
'full_path'
,
expect
(
group_kind_json_response
.
keys
).
to
include
(
'id'
,
'kind'
,
'name'
,
'path'
,
'full_path'
,
'parent_id'
,
'members_count_with_descendants'
)
'parent_id'
,
'members_count_with_descendants'
)
...
@@ -34,7 +34,7 @@ describe API::Namespaces do
...
@@ -34,7 +34,7 @@ describe API::Namespaces do
it
"admin: returns an array of all namespaces"
do
it
"admin: returns an array of all namespaces"
do
get
api
(
"/namespaces"
,
admin
)
get
api
(
"/namespaces"
,
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
.
length
).
to
eq
(
Namespace
.
count
)
expect
(
json_response
.
length
).
to
eq
(
Namespace
.
count
)
...
@@ -43,7 +43,7 @@ describe API::Namespaces do
...
@@ -43,7 +43,7 @@ describe API::Namespaces do
it
"admin: returns an array of matched namespaces"
do
it
"admin: returns an array of matched namespaces"
do
get
api
(
"/namespaces?search=
#{
group2
.
name
}
"
,
admin
)
get
api
(
"/namespaces?search=
#{
group2
.
name
}
"
,
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
.
length
).
to
eq
(
1
)
expect
(
json_response
.
length
).
to
eq
(
1
)
...
@@ -77,7 +77,7 @@ describe API::Namespaces do
...
@@ -77,7 +77,7 @@ describe API::Namespaces do
it
"user: returns an array of namespaces"
do
it
"user: returns an array of namespaces"
do
get
api
(
"/namespaces"
,
user
)
get
api
(
"/namespaces"
,
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
.
length
).
to
eq
(
1
)
expect
(
json_response
.
length
).
to
eq
(
1
)
...
@@ -86,7 +86,7 @@ describe API::Namespaces do
...
@@ -86,7 +86,7 @@ describe API::Namespaces do
it
"admin: returns an array of matched namespaces"
do
it
"admin: returns an array of matched namespaces"
do
get
api
(
"/namespaces?search=
#{
user
.
username
}
"
,
user
)
get
api
(
"/namespaces?search=
#{
user
.
username
}
"
,
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
.
length
).
to
eq
(
1
)
expect
(
json_response
.
length
).
to
eq
(
1
)
...
@@ -102,7 +102,7 @@ describe API::Namespaces do
...
@@ -102,7 +102,7 @@ describe API::Namespaces do
it
'returns namespace details'
do
it
'returns namespace details'
do
get
api
(
"/namespaces/
#{
namespace_id
}
"
,
request_actor
)
get
api
(
"/namespaces/
#{
namespace_id
}
"
,
request_actor
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'id'
]).
to
eq
(
requested_namespace
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
requested_namespace
.
id
)
expect
(
json_response
[
'path'
]).
to
eq
(
requested_namespace
.
path
)
expect
(
json_response
[
'path'
]).
to
eq
(
requested_namespace
.
path
)
...
@@ -153,7 +153,7 @@ describe API::Namespaces do
...
@@ -153,7 +153,7 @@ describe API::Namespaces do
it
'returns not-found'
do
it
'returns not-found'
do
get
api
(
'/namespaces/0'
,
request_actor
)
get
api
(
'/namespaces/0'
,
request_actor
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
@@ -162,7 +162,7 @@ describe API::Namespaces do
...
@@ -162,7 +162,7 @@ describe API::Namespaces do
it
'returns authentication error'
do
it
'returns authentication error'
do
get
api
(
"/namespaces/
#{
group1
.
id
}
"
)
get
api
(
"/namespaces/
#{
group1
.
id
}
"
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
...
@@ -174,7 +174,7 @@ describe API::Namespaces do
...
@@ -174,7 +174,7 @@ describe API::Namespaces do
it
'returns not-found'
do
it
'returns not-found'
do
get
api
(
"/namespaces/
#{
group2
.
id
}
"
,
request_actor
)
get
api
(
"/namespaces/
#{
group2
.
id
}
"
,
request_actor
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
@@ -182,7 +182,7 @@ describe API::Namespaces do
...
@@ -182,7 +182,7 @@ describe API::Namespaces do
it
'returns not-found'
do
it
'returns not-found'
do
get
api
(
"/namespaces/
#{
user2
.
namespace
.
id
}
"
,
request_actor
)
get
api
(
"/namespaces/
#{
user2
.
namespace
.
id
}
"
,
request_actor
)
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/notes_spec.rb
View file @
765fc43b
...
@@ -72,7 +72,7 @@ describe API::Notes do
...
@@ -72,7 +72,7 @@ describe API::Notes do
it
"returns an empty array"
do
it
"returns an empty array"
do
get
api
(
"/projects/
#{
ext_proj
.
id
}
/issues/
#{
ext_issue
.
iid
}
/notes"
,
user
)
get
api
(
"/projects/
#{
ext_proj
.
id
}
/issues/
#{
ext_issue
.
iid
}
/notes"
,
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
).
to
be_empty
expect
(
json_response
).
to
be_empty
...
@@ -86,7 +86,7 @@ describe API::Notes do
...
@@ -86,7 +86,7 @@ describe API::Notes do
it
"returns 404"
do
it
"returns 404"
do
get
api
(
"/projects/
#{
ext_proj
.
id
}
/issues/
#{
ext_issue
.
iid
}
/notes"
,
user
)
get
api
(
"/projects/
#{
ext_proj
.
id
}
/issues/
#{
ext_issue
.
iid
}
/notes"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
@@ -95,7 +95,7 @@ describe API::Notes do
...
@@ -95,7 +95,7 @@ describe API::Notes do
it
"returns a non-empty array"
do
it
"returns a non-empty array"
do
get
api
(
"/projects/
#{
ext_proj
.
id
}
/issues/
#{
ext_issue
.
iid
}
/notes"
,
private_user
)
get
api
(
"/projects/
#{
ext_proj
.
id
}
/issues/
#{
ext_issue
.
iid
}
/notes"
,
private_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
[
'body'
]).
to
eq
(
cross_reference_note
.
note
)
expect
(
json_response
.
first
[
'body'
]).
to
eq
(
cross_reference_note
.
note
)
...
@@ -114,7 +114,7 @@ describe API::Notes do
...
@@ -114,7 +114,7 @@ describe API::Notes do
shared_examples
'a notes request'
do
shared_examples
'a notes request'
do
it
'is a note array response'
do
it
'is a note array response'
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
end
end
...
@@ -177,7 +177,7 @@ describe API::Notes do
...
@@ -177,7 +177,7 @@ describe API::Notes do
it
"returns a 404 error"
do
it
"returns a 404 error"
do
get
api
(
"/projects/
#{
ext_proj
.
id
}
/issues/
#{
ext_issue
.
iid
}
/notes/
#{
cross_reference_note
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
ext_proj
.
id
}
/issues/
#{
ext_issue
.
iid
}
/notes/
#{
cross_reference_note
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
context
"when issue is confidential"
do
context
"when issue is confidential"
do
...
@@ -188,7 +188,7 @@ describe API::Notes do
...
@@ -188,7 +188,7 @@ describe API::Notes do
it
"returns 404"
do
it
"returns 404"
do
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/notes/
#{
issue_note
.
id
}
"
,
private_user
)
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/notes/
#{
issue_note
.
id
}
"
,
private_user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
...
@@ -197,7 +197,7 @@ describe API::Notes do
...
@@ -197,7 +197,7 @@ describe API::Notes do
it
"returns an issue note by id"
do
it
"returns an issue note by id"
do
get
api
(
"/projects/
#{
ext_proj
.
id
}
/issues/
#{
ext_issue
.
iid
}
/notes/
#{
cross_reference_note
.
id
}
"
,
private_user
)
get
api
(
"/projects/
#{
ext_proj
.
id
}
/issues/
#{
ext_issue
.
iid
}
/notes/
#{
cross_reference_note
.
id
}
"
,
private_user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'body'
]).
to
eq
(
cross_reference_note
.
note
)
expect
(
json_response
[
'body'
]).
to
eq
(
cross_reference_note
.
note
)
end
end
end
end
...
@@ -237,7 +237,7 @@ describe API::Notes do
...
@@ -237,7 +237,7 @@ describe API::Notes do
it
'returns 200 status'
do
it
'returns 200 status'
do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
end
end
it
'creates a new note'
do
it
'creates a new note'
do
...
@@ -251,7 +251,7 @@ describe API::Notes do
...
@@ -251,7 +251,7 @@ describe API::Notes do
it
'returns 403 status'
do
it
'returns 403 status'
do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
it
'does not create a new note'
do
it
'does not create a new note'
do
...
...
spec/requests/api/notification_settings_spec.rb
View file @
765fc43b
...
@@ -11,7 +11,7 @@ describe API::NotificationSettings do
...
@@ -11,7 +11,7 @@ describe API::NotificationSettings do
it
"returns global notification settings for the current user"
do
it
"returns global notification settings for the current user"
do
get
api
(
"/notification_settings"
,
user
)
get
api
(
"/notification_settings"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
[
'notification_email'
]).
to
eq
(
user
.
notification_email
)
expect
(
json_response
[
'notification_email'
]).
to
eq
(
user
.
notification_email
)
expect
(
json_response
[
'level'
]).
to
eq
(
user
.
global_notification_setting
.
level
)
expect
(
json_response
[
'level'
]).
to
eq
(
user
.
global_notification_setting
.
level
)
...
@@ -24,7 +24,7 @@ describe API::NotificationSettings do
...
@@ -24,7 +24,7 @@ describe API::NotificationSettings do
it
"updates global notification settings for the current user"
do
it
"updates global notification settings for the current user"
do
put
api
(
"/notification_settings"
,
user
),
params:
{
level:
'watch'
,
notification_email:
email
.
email
}
put
api
(
"/notification_settings"
,
user
),
params:
{
level:
'watch'
,
notification_email:
email
.
email
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'notification_email'
]).
to
eq
(
email
.
email
)
expect
(
json_response
[
'notification_email'
]).
to
eq
(
email
.
email
)
expect
(
user
.
reload
.
notification_email
).
to
eq
(
email
.
email
)
expect
(
user
.
reload
.
notification_email
).
to
eq
(
email
.
email
)
expect
(
json_response
[
'level'
]).
to
eq
(
user
.
reload
.
global_notification_setting
.
level
)
expect
(
json_response
[
'level'
]).
to
eq
(
user
.
reload
.
global_notification_setting
.
level
)
...
@@ -35,7 +35,7 @@ describe API::NotificationSettings do
...
@@ -35,7 +35,7 @@ describe API::NotificationSettings do
it
"fails on non-user email address"
do
it
"fails on non-user email address"
do
put
api
(
"/notification_settings"
,
user
),
params:
{
notification_email:
'invalid@example.com'
}
put
api
(
"/notification_settings"
,
user
),
params:
{
notification_email:
'invalid@example.com'
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
...
@@ -43,7 +43,7 @@ describe API::NotificationSettings do
...
@@ -43,7 +43,7 @@ describe API::NotificationSettings do
it
"returns group level notification settings for the current user"
do
it
"returns group level notification settings for the current user"
do
get
api
(
"/groups/
#{
group
.
id
}
/notification_settings"
,
user
)
get
api
(
"/groups/
#{
group
.
id
}
/notification_settings"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
[
'level'
]).
to
eq
(
user
.
notification_settings_for
(
group
).
level
)
expect
(
json_response
[
'level'
]).
to
eq
(
user
.
notification_settings_for
(
group
).
level
)
end
end
...
@@ -53,7 +53,7 @@ describe API::NotificationSettings do
...
@@ -53,7 +53,7 @@ describe API::NotificationSettings do
it
"updates group level notification settings for the current user"
do
it
"updates group level notification settings for the current user"
do
put
api
(
"/groups/
#{
group
.
id
}
/notification_settings"
,
user
),
params:
{
level:
'watch'
}
put
api
(
"/groups/
#{
group
.
id
}
/notification_settings"
,
user
),
params:
{
level:
'watch'
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'level'
]).
to
eq
(
user
.
reload
.
notification_settings_for
(
group
).
level
)
expect
(
json_response
[
'level'
]).
to
eq
(
user
.
reload
.
notification_settings_for
(
group
).
level
)
end
end
end
end
...
@@ -62,7 +62,7 @@ describe API::NotificationSettings do
...
@@ -62,7 +62,7 @@ describe API::NotificationSettings do
it
"returns project level notification settings for the current user"
do
it
"returns project level notification settings for the current user"
do
get
api
(
"/projects/
#{
project
.
id
}
/notification_settings"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/notification_settings"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
).
to
be_a
Hash
expect
(
json_response
[
'level'
]).
to
eq
(
user
.
notification_settings_for
(
project
).
level
)
expect
(
json_response
[
'level'
]).
to
eq
(
user
.
notification_settings_for
(
project
).
level
)
end
end
...
@@ -72,7 +72,7 @@ describe API::NotificationSettings do
...
@@ -72,7 +72,7 @@ describe API::NotificationSettings do
it
"updates project level notification settings for the current user"
do
it
"updates project level notification settings for the current user"
do
put
api
(
"/projects/
#{
project
.
id
}
/notification_settings"
,
user
),
params:
{
level:
'custom'
,
new_note:
true
}
put
api
(
"/projects/
#{
project
.
id
}
/notification_settings"
,
user
),
params:
{
level:
'custom'
,
new_note:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'level'
]).
to
eq
(
user
.
reload
.
notification_settings_for
(
project
).
level
)
expect
(
json_response
[
'level'
]).
to
eq
(
user
.
reload
.
notification_settings_for
(
project
).
level
)
expect
(
json_response
[
'events'
][
'new_note'
]).
to
be_truthy
expect
(
json_response
[
'events'
][
'new_note'
]).
to
be_truthy
expect
(
json_response
[
'events'
][
'new_issue'
]).
to
be_falsey
expect
(
json_response
[
'events'
][
'new_issue'
]).
to
be_falsey
...
@@ -83,7 +83,7 @@ describe API::NotificationSettings do
...
@@ -83,7 +83,7 @@ describe API::NotificationSettings do
it
"fails on invalid level"
do
it
"fails on invalid level"
do
put
api
(
"/projects/
#{
project
.
id
}
/notification_settings"
,
user
),
params:
{
level:
'invalid'
}
put
api
(
"/projects/
#{
project
.
id
}
/notification_settings"
,
user
),
params:
{
level:
'invalid'
}
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/oauth_tokens_spec.rb
View file @
765fc43b
...
@@ -14,7 +14,7 @@ describe 'OAuth tokens' do
...
@@ -14,7 +14,7 @@ describe 'OAuth tokens' do
request_oauth_token
(
user
)
request_oauth_token
(
user
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
expect
(
json_response
[
'error'
]).
to
eq
(
'invalid_grant'
)
expect
(
json_response
[
'error'
]).
to
eq
(
'invalid_grant'
)
end
end
end
end
...
@@ -25,7 +25,7 @@ describe 'OAuth tokens' do
...
@@ -25,7 +25,7 @@ describe 'OAuth tokens' do
request_oauth_token
(
user
)
request_oauth_token
(
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'access_token'
]).
not_to
be_nil
expect
(
json_response
[
'access_token'
]).
not_to
be_nil
end
end
end
end
...
@@ -33,7 +33,7 @@ describe 'OAuth tokens' do
...
@@ -33,7 +33,7 @@ describe 'OAuth tokens' do
shared_examples
'does not create an access token'
do
shared_examples
'does not create an access token'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
it
{
expect
(
response
).
to
have_gitlab_http_status
(
401
)
}
it
{
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
}
end
end
context
'when user is blocked'
do
context
'when user is blocked'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment