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
341838ac
Commit
341838ac
authored
Jan 21, 2019
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only check overall approvals required when with no rule
This excludes code owner rule
parent
2d2ea563
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
8 deletions
+20
-8
ee/app/models/approval_state.rb
ee/app/models/approval_state.rb
+16
-4
ee/spec/models/approval_state_spec.rb
ee/spec/models/approval_state_spec.rb
+4
-4
No files found.
ee/app/models/approval_state.rb
View file @
341838ac
...
...
@@ -43,16 +43,24 @@ class ApprovalState
def
approval_needed?
return
false
unless
project
.
feature_available?
(
:merge_request_approvers
)
overall_approvals_required
>
0
||
wrapped_approval_rules
.
any?
{
|
rule
|
rule
.
approvals_required
>
0
}
if
regular_rules
.
empty?
overall_approvals_required
>
0
else
wrapped_approval_rules
.
any?
{
|
rule
|
rule
.
approvals_required
>
0
}
end
end
def
overall_approvals_required
@overall_approvals_required
||=
project
.
approvals_before_merge
@overall_approvals_required
||=
[
project
.
approvals_before_merge
,
merge_request
.
approvals_before_merge
].
max
end
def
approved?
strong_memoize
(
:approved
)
do
(
overall_approvals_required
==
0
||
approvals
.
size
>=
overall_approvals_required
)
&&
wrapped_approval_rules
.
all?
(
&
:approved?
)
if
regular_rules
.
empty?
approvals
.
size
>=
overall_approvals_required
else
wrapped_approval_rules
.
all?
(
&
:approved?
)
end
end
end
...
...
@@ -64,7 +72,11 @@ class ApprovalState
# considered approved.
def
approvals_left
strong_memoize
(
:approvals_left
)
do
wrapped_approval_rules
.
sum
(
&
:approvals_left
)
if
regular_rules
.
empty?
[
overall_approvals_required
-
approved_approvers
.
size
,
0
].
max
else
wrapped_approval_rules
.
sum
(
&
:approvals_left
)
end
end
end
...
...
ee/spec/models/approval_state_spec.rb
View file @
341838ac
...
...
@@ -170,8 +170,8 @@ describe ApprovalState do
project
.
update
(
approvals_before_merge:
3
)
end
it
'returns
false
'
do
expect
(
subject
.
approved?
).
to
eq
(
fals
e
)
it
'returns
true as overall approvals_required is ignored
'
do
expect
(
subject
.
approved?
).
to
eq
(
tru
e
)
end
end
end
...
...
@@ -714,8 +714,8 @@ describe ApprovalState do
project
.
update
(
approvals_before_merge:
3
)
end
it
'returns
false
'
do
expect
(
subject
.
approved?
).
to
eq
(
fals
e
)
it
'returns
true as overall approvals_required is ignored
'
do
expect
(
subject
.
approved?
).
to
eq
(
tru
e
)
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