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
f2eed8e8
Commit
f2eed8e8
authored
Jan 11, 2019
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port "revent commit authors from self approvaling MR"
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/9007
parent
e45bbba6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
10 deletions
+9
-10
ee/app/models/approval_state.rb
ee/app/models/approval_state.rb
+3
-6
ee/spec/models/approval_state_spec.rb
ee/spec/models/approval_state_spec.rb
+6
-4
No files found.
ee/app/models/approval_state.rb
View file @
f2eed8e8
...
...
@@ -20,15 +20,12 @@ class ApprovalState
# Excludes the author if 'self-approval' isn't explicitly enabled on project settings.
def
self
.
filter_author
(
users
,
merge_request
)
return
users
unless
merge_request
.
author_id
return
users
if
merge_request
.
target_project
.
merge_requests_author_approval?
if
users
.
is_a?
(
ActiveRecord
::
Relation
)
&&
!
users
.
loaded?
users
.
where
.
not
(
id:
merge_request
.
author
_id
)
users
.
where
.
not
(
id:
merge_request
.
author
s
)
else
users
.
dup
users
.
delete
(
merge_request
.
author
)
users
users
-
merge_request
.
authors
end
end
...
...
@@ -106,7 +103,7 @@ class ApprovalState
# That is, they're included/excluded from that list accordingly.
return
true
if
unactioned_approvers
.
include?
(
user
)
# We can safely unauthorize authors if it reaches this guard clause.
return
false
if
user
==
merge_request
.
author
return
false
if
merge_request
.
authors
.
include?
(
user
)
return
false
unless
user
.
can?
(
:update_merge_request
,
merge_request
)
any_approver_allowed?
&&
merge_request
.
approvals
.
where
(
user:
user
).
empty?
...
...
ee/spec/models/approval_state_spec.rb
View file @
f2eed8e8
...
...
@@ -27,15 +27,17 @@ describe ApprovalState do
shared_examples
'filtering author'
do
before
do
allow
(
merge_request
).
to
receive
(
:authors
).
and_return
([
merge_request
.
author
,
create
(
:user
,
username:
'commiter'
)])
project
.
update
(
merge_requests_author_approval:
merge_requests_author_approval
)
create_rule
(
users:
[
merge_request
.
author
]
)
create_rule
(
users:
merge_request
.
authors
)
end
context
'when self approval is disabled'
do
let
(
:merge_requests_author_approval
)
{
false
}
it
'excludes author'
do
expect
(
results
).
not_to
include
(
merge_request
.
author
)
it
'excludes author
s
'
do
expect
(
results
).
not_to
include
(
*
merge_request
.
authors
)
end
end
...
...
@@ -43,7 +45,7 @@ describe ApprovalState do
let
(
:merge_requests_author_approval
)
{
true
}
it
'includes author'
do
expect
(
results
).
to
include
(
merge_request
.
author
)
expect
(
results
).
to
include
(
*
merge_request
.
authors
)
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