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
bf470fc9
Commit
bf470fc9
authored
Jan 15, 2020
by
Igor Drozdov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to delete any-approval rule using API call
User defined rules are allowed to be deleted
parent
17389160
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
2 deletions
+14
-2
ee/app/models/concerns/approval_rule_like.rb
ee/app/models/concerns/approval_rule_like.rb
+4
-0
ee/app/policies/approval_merge_request_rule_policy.rb
ee/app/policies/approval_merge_request_rule_policy.rb
+1
-1
ee/spec/policies/approval_merge_request_rule_policy_spec.rb
ee/spec/policies/approval_merge_request_rule_policy_spec.rb
+9
-1
No files found.
ee/app/models/concerns/approval_rule_like.rb
View file @
bf470fc9
...
...
@@ -50,4 +50,8 @@ module ApprovalRuleLike
def
any_approver?
raise
NotImplementedError
end
def
user_defined?
regular?
||
any_approver?
end
end
ee/app/policies/approval_merge_request_rule_policy.rb
View file @
bf470fc9
...
...
@@ -4,7 +4,7 @@ class ApprovalMergeRequestRulePolicy < BasePolicy
delegate
{
@subject
.
merge_request
}
condition
(
:editable
)
do
can?
(
:update_merge_request
,
@subject
.
merge_request
)
&&
@subject
.
regular
?
can?
(
:update_merge_request
,
@subject
.
merge_request
)
&&
@subject
.
user_defined
?
end
rule
{
editable
}.
enable
:edit_approval_rule
...
...
ee/spec/policies/approval_merge_request_rule_policy_spec.rb
View file @
bf470fc9
...
...
@@ -15,7 +15,15 @@ describe ApprovalMergeRequestRulePolicy do
expect
(
permissions
(
merge_request
.
author
,
approval_rule
)).
to
be_allowed
(
:edit_approval_rule
)
end
context
'when rule is not regular type'
do
context
'when rule is any-approval'
do
let
(
:approval_rule
)
{
build
(
:any_approver_rule
,
merge_request:
merge_request
)
}
it
'allows updating approval rule'
do
expect
(
permissions
(
merge_request
.
author
,
approval_rule
)).
to
be_allowed
(
:edit_approval_rule
)
end
end
context
'when rule is not user editable'
do
let
(
:approval_rule
)
{
create
(
:code_owner_rule
,
merge_request:
merge_request
)
}
it
'disallows updating approval rule'
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