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
6d755dd7
Commit
6d755dd7
authored
May 22, 2020
by
Kerri Miller
Committed by
Robert Speicher
May 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update API responses to include "section" of ApprovalMergeRequestRule
parent
9b9570f7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
2 deletions
+30
-2
ee/app/models/approval_project_rule.rb
ee/app/models/approval_project_rule.rb
+4
-0
ee/app/models/approval_wrapped_rule.rb
ee/app/models/approval_wrapped_rule.rb
+1
-1
ee/lib/ee/api/entities/merge_request_approval_rule.rb
ee/lib/ee/api/entities/merge_request_approval_rule.rb
+1
-0
ee/spec/fixtures/api/schemas/public_api/v4/merge_request_approval_rule.json
...pi/schemas/public_api/v4/merge_request_approval_rule.json
+1
-0
ee/spec/requests/api/merge_request_approval_rules_spec.rb
ee/spec/requests/api/merge_request_approval_rules_spec.rb
+1
-0
ee/spec/requests/api/merge_request_approvals_spec.rb
ee/spec/requests/api/merge_request_approvals_spec.rb
+22
-1
No files found.
ee/app/models/approval_project_rule.rb
View file @
6d755dd7
...
...
@@ -37,6 +37,10 @@ class ApprovalProjectRule < ApplicationRecord
nil
end
def
section
nil
end
def
apply_report_approver_rules_to
(
merge_request
)
report_type
=
report_type_for
(
self
)
rule
=
merge_request
...
...
ee/app/models/approval_wrapped_rule.rb
View file @
6d755dd7
...
...
@@ -11,7 +11,7 @@ class ApprovalWrappedRule
def_delegators
(
:@approval_rule
,
:regular?
,
:any_approver?
,
:code_owner?
,
:report_approver?
,
:overridden?
,
:id
,
:name
,
:users
,
:groups
,
:code_owner
,
:source_rule
,
:rule_type
,
:approvals_required
)
:source_rule
,
:rule_type
,
:approvals_required
,
:section
)
def
self
.
wrap
(
merge_request
,
rule
)
if
rule
.
any_approver?
...
...
ee/lib/ee/api/entities/merge_request_approval_rule.rb
View file @
6d755dd7
...
...
@@ -8,6 +8,7 @@ module EE
expose
:approvals_required
end
expose
:section
expose
:source_rule
,
using:
MergeRequestApprovalRule
::
SourceRule
expose
:overridden?
,
as: :overridden
end
...
...
ee/spec/fixtures/api/schemas/public_api/v4/merge_request_approval_rule.json
View file @
6d755dd7
...
...
@@ -6,6 +6,7 @@
"approvals_required"
:
{
"type"
:
"integer"
},
"contains_hidden_groups"
:
{
"type"
:
"boolean"
},
"rule_type"
:
{
"type"
:
"string"
},
"section"
:
{
"type"
:
[
"null"
,
"string"
]
},
"source_rule"
:
{
"type"
:[
"null"
,
"object"
],
"properties"
:
{}
...
...
ee/spec/requests/api/merge_request_approval_rules_spec.rb
View file @
6d755dd7
...
...
@@ -98,6 +98,7 @@ describe API::MergeRequestApprovalRules do
expect
(
rules
.
first
[
'name'
]).
to
eq
(
mr_approval_rule
.
name
)
expect
(
rules
.
first
[
'approvals_required'
]).
to
eq
(
mr_approval_rule
.
approvals_required
)
expect
(
rules
.
first
[
'rule_type'
]).
to
eq
(
mr_approval_rule
.
rule_type
)
expect
(
rules
.
first
[
'section'
]).
to
be_nil
expect
(
rules
.
first
[
'contains_hidden_groups'
]).
to
eq
(
false
)
expect
(
rules
.
first
[
'source_rule'
]).
to
be_nil
expect
(
rules
.
first
[
'eligible_approvers'
]).
to
match
([
hash_including
(
'id'
=>
approver
.
id
)])
...
...
ee/spec/requests/api/merge_request_approvals_spec.rb
View file @
6d755dd7
...
...
@@ -174,7 +174,28 @@ describe API::MergeRequestApprovals do
expect
(
rule_response
[
'name'
]).
to
eq
(
'foo'
)
expect
(
rule_response
[
'approvers'
][
0
][
'username'
]).
to
eq
(
approver
.
username
)
expect
(
rule_response
[
'approved_by'
][
0
][
'username'
]).
to
eq
(
approver
.
username
)
expect
(
rule_response
[
'source_rule'
]).
to
eq
(
nil
)
expect
(
rule_response
[
'source_rule'
]).
to
be_nil
expect
(
rule_response
[
'section'
]).
to
be_nil
end
context
"when rule has a section"
do
let
(
:rule
)
do
create
(
:code_owner_rule
,
merge_request:
merge_request
,
approvals_required:
2
,
name:
"foo"
,
section:
"Example Section"
)
end
it
"exposes the value of section when set"
do
get
api
(
url
,
user
)
rule_response
=
json_response
[
"rules"
].
first
expect
(
rule_response
[
"section"
]).
to
eq
(
rule
.
section
)
end
end
context
'when target_branch is specified'
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