Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
cd6af77f
Commit
cd6af77f
authored
Feb 14, 2019
by
Robert Schilling
Committed by
Nick Thomas
Feb 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: Expose if the user can merge a given merge request
parent
6d1273cf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
0 deletions
+24
-0
changelogs/unreleased/44740-api-to-verify-a-given-user-has-right-to-merge-a-given-mergerequest.yml
...-a-given-user-has-right-to-merge-a-given-mergerequest.yml
+5
-0
doc/api/merge_requests.md
doc/api/merge_requests.md
+3
-0
lib/api/entities.rb
lib/api/entities.rb
+6
-0
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+10
-0
No files found.
changelogs/unreleased/44740-api-to-verify-a-given-user-has-right-to-merge-a-given-mergerequest.yml
0 → 100644
View file @
cd6af77f
---
title
:
'
API:
Expose
if
the
current
user
can
merge
a
MR'
merge_request
:
25207
author
:
Robert Schilling
type
:
added
doc/api/merge_requests.md
View file @
cd6af77f
...
...
@@ -435,6 +435,9 @@ Parameters:
"avatar_url"
:
null
,
"web_url"
:
"https://gitlab.example.com/admin"
},
"user"
:
{
"can_merge"
:
false
}
"assignee"
:
{
"id"
:
1
,
"name"
:
"Administrator"
,
...
...
lib/api/entities.rb
View file @
cd6af77f
...
...
@@ -732,6 +732,12 @@ module API
def
build_available?
(
options
)
options
[
:project
]
&
.
feature_available?
(
:builds
,
options
[
:current_user
])
end
expose
:user
do
expose
:can_merge
do
|
merge_request
,
options
|
merge_request
.
can_be_merged_by?
(
options
[
:current_user
])
end
end
end
class
MergeRequestChanges
<
MergeRequest
...
...
spec/requests/api/merge_requests_spec.rb
View file @
cd6af77f
...
...
@@ -372,6 +372,7 @@ describe API::MergeRequests do
expect
(
json_response
[
'force_close_merge_request'
]).
to
be_falsy
expect
(
json_response
[
'changes_count'
]).
to
eq
(
merge_request
.
merge_request_diff
.
real_size
)
expect
(
json_response
[
'merge_error'
]).
to
eq
(
merge_request
.
merge_error
)
expect
(
json_response
[
'user'
][
'can_merge'
]).
to
be_truthy
expect
(
json_response
).
not_to
include
(
'rebase_in_progress'
)
end
...
...
@@ -499,6 +500,15 @@ describe API::MergeRequests do
expect
(
json_response
[
'allow_maintainer_to_push'
]).
to
be_truthy
end
end
it
'indicates if a user cannot merge the MR'
do
user2
=
create
(
:user
)
project
.
add_reporter
(
user2
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user2
)
expect
(
json_response
[
'user'
][
'can_merge'
]).
to
be_falsy
end
end
describe
'GET /projects/:id/merge_requests/:merge_request_iid/participants'
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