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
d849f58a
Commit
d849f58a
authored
Dec 04, 2020
by
David Kim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add reviewers to MergeRequest API responses
parent
36513a0e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
1 deletion
+29
-1
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
lib/api/entities/merge_request_basic.rb
lib/api/entities/merge_request_basic.rb
+1
-0
spec/lib/api/entities/merge_request_basic_spec.rb
spec/lib/api/entities/merge_request_basic_spec.rb
+27
-0
No files found.
app/models/merge_request.rb
View file @
d849f58a
...
@@ -274,7 +274,7 @@ class MergeRequest < ApplicationRecord
...
@@ -274,7 +274,7 @@ class MergeRequest < ApplicationRecord
scope
:with_api_entity_associations
,
->
{
scope
:with_api_entity_associations
,
->
{
preload_routables
preload_routables
.
preload
(
:assignees
,
:author
,
:unresolved_notes
,
:labels
,
:milestone
,
.
preload
(
:assignees
,
:author
,
:unresolved_notes
,
:labels
,
:milestone
,
:timelogs
,
:latest_merge_request_diff
,
:timelogs
,
:latest_merge_request_diff
,
:reviewers
,
target_project: :project_feature
,
target_project: :project_feature
,
metrics:
[
:latest_closed_by
,
:merged_by
])
metrics:
[
:latest_closed_by
,
:merged_by
])
}
}
...
...
lib/api/entities/merge_request_basic.rb
View file @
d849f58a
...
@@ -27,6 +27,7 @@ module API
...
@@ -27,6 +27,7 @@ module API
expose
(
:downvotes
)
{
|
merge_request
,
options
|
issuable_metadata
.
downvotes
}
expose
(
:downvotes
)
{
|
merge_request
,
options
|
issuable_metadata
.
downvotes
}
expose
:author
,
:assignees
,
:assignee
,
using:
Entities
::
UserBasic
expose
:author
,
:assignees
,
:assignee
,
using:
Entities
::
UserBasic
expose
:reviewers
,
if:
->
(
merge_request
,
_
)
{
merge_request
.
allows_reviewers?
},
using:
Entities
::
UserBasic
expose
:source_project_id
,
:target_project_id
expose
:source_project_id
,
:target_project_id
expose
:labels
do
|
merge_request
,
options
|
expose
:labels
do
|
merge_request
,
options
|
if
options
[
:with_labels_details
]
if
options
[
:with_labels_details
]
...
...
spec/lib/api/entities/merge_request_basic_spec.rb
View file @
d849f58a
...
@@ -40,4 +40,31 @@ RSpec.describe ::API::Entities::MergeRequestBasic do
...
@@ -40,4 +40,31 @@ RSpec.describe ::API::Entities::MergeRequestBasic do
expect
(
batch
.
count
).
to
be_within
(
3
*
query
.
count
).
of
(
control
.
count
)
expect
(
batch
.
count
).
to
be_within
(
3
*
query
.
count
).
of
(
control
.
count
)
end
end
end
end
context
'reviewers'
do
context
"when merge_request_reviewers FF is enabled"
do
before
do
stub_feature_flags
(
merge_request_reviewers:
true
)
merge_request
.
reviewers
=
[
user
]
end
it
'includes assigned reviewers'
do
result
=
Gitlab
::
Json
.
parse
(
present
(
merge_request
).
to_json
)
expect
(
result
[
'reviewers'
][
0
][
'username'
]).
to
eq
user
.
username
end
end
context
"when merge_request_reviewers FF is disabled"
do
before
do
stub_feature_flags
(
merge_request_reviewers:
false
)
end
it
'does not include reviewers'
do
result
=
Gitlab
::
Json
.
parse
(
present
(
merge_request
).
to_json
)
expect
(
result
.
keys
).
not_to
include
(
'reviewers'
)
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment