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
ad1f1472
Commit
ad1f1472
authored
Jul 23, 2020
by
Robert Hunt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add target and source branch data to entity
parent
3d56dc83
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
2 deletions
+31
-2
ee/app/serializers/merge_request_compliance_entity.rb
ee/app/serializers/merge_request_compliance_entity.rb
+13
-1
ee/changelogs/unreleased/216279-add-source-and-destination-branch-data-to-compliance-entity.yml
...urce-and-destination-branch-data-to-compliance-entity.yml
+5
-0
ee/spec/serializers/merge_request_compliance_entity_spec.rb
ee/spec/serializers/merge_request_compliance_entity_spec.rb
+13
-1
No files found.
ee/app/serializers/merge_request_compliance_entity.rb
View file @
ad1f1472
...
@@ -24,9 +24,13 @@ class MergeRequestComplianceEntity < Grape::Entity
...
@@ -24,9 +24,13 @@ class MergeRequestComplianceEntity < Grape::Entity
expose
:approved_by_users
,
using:
API
::
Entities
::
UserBasic
expose
:approved_by_users
,
using:
API
::
Entities
::
UserBasic
expose
:pipeline_status
,
if:
->
(
*
)
{
can_read_pipeline?
},
with:
DetailedStatusEntity
expose
:pipeline_status
,
if:
->
(
*
)
{
can_read_pipeline?
},
with:
DetailedStatusEntity
expose
:approval_status
expose
:approval_status
expose
:target_branch
expose
:target_branch_uri
,
if:
->
(
merge_request
)
{
merge_request
.
target_branch_exists?
}
expose
:source_branch
expose
:source_branch_uri
,
if:
->
(
merge_request
)
{
merge_request
.
source_branch_exists?
}
private
private
alias_method
:merge_request
,
:object
alias_method
:merge_request
,
:object
...
@@ -53,4 +57,12 @@ class MergeRequestComplianceEntity < Grape::Entity
...
@@ -53,4 +57,12 @@ class MergeRequestComplianceEntity < Grape::Entity
SUCCESS_APPROVAL_STATUS
SUCCESS_APPROVAL_STATUS
end
end
def
target_branch_uri
project_ref_path
(
merge_request
.
project
,
merge_request
.
target_branch
)
end
def
source_branch_uri
project_ref_path
(
merge_request
.
project
,
merge_request
.
source_branch
)
end
end
end
ee/changelogs/unreleased/216279-add-source-and-destination-branch-data-to-compliance-entity.yml
0 → 100644
View file @
ad1f1472
---
title
:
Add source and destination branch data to compliance entity
merge_request
:
37630
author
:
type
:
added
ee/spec/serializers/merge_request_compliance_entity_spec.rb
View file @
ad1f1472
...
@@ -17,7 +17,19 @@ RSpec.describe MergeRequestComplianceEntity do
...
@@ -17,7 +17,19 @@ RSpec.describe MergeRequestComplianceEntity do
it
'includes merge request attributes for compliance'
do
it
'includes merge request attributes for compliance'
do
expect
(
subject
).
to
include
(
expect
(
subject
).
to
include
(
:id
,
:title
,
:merged_at
,
:milestone
,
:path
,
:issuable_reference
,
:author
,
:approved_by_users
,
:approval_status
:id
,
:title
,
:merged_at
,
:milestone
,
:path
,
:issuable_reference
,
:author
,
:approved_by_users
,
:approval_status
,
:target_branch
,
:target_branch_uri
,
:source_branch
,
:source_branch_uri
)
)
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