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
1353b579
Commit
1353b579
authored
Dec 17, 2019
by
Igor Drozdov
Committed by
Mike Kozono
Jan 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show regular rules without approvers
parent
b8bc2883
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
59 deletions
+11
-59
changelogs/unreleased/display-rules-without-approvers.yml
changelogs/unreleased/display-rules-without-approvers.yml
+5
-0
ee/app/models/approval_state.rb
ee/app/models/approval_state.rb
+1
-4
ee/spec/models/approval_state_spec.rb
ee/spec/models/approval_state_spec.rb
+5
-55
No files found.
changelogs/unreleased/display-rules-without-approvers.yml
0 → 100644
View file @
1353b579
---
title
:
Show regular rules without approvers
merge_request
:
21918
author
:
type
:
fixed
ee/app/models/approval_state.rb
View file @
1353b579
...
@@ -176,11 +176,8 @@ class ApprovalState
...
@@ -176,11 +176,8 @@ class ApprovalState
def
user_defined_merge_request_rules
def
user_defined_merge_request_rules
strong_memoize
(
:user_defined_merge_request_rules
)
do
strong_memoize
(
:user_defined_merge_request_rules
)
do
# Filter out the rules without approvers since such rules aren't useful
regular_rules
=
regular_rules
=
wrapped_rules
wrapped_rules
.
select
(
&
:regular?
).
sort_by
(
&
:id
)
.
select
{
|
rule
|
rule
.
regular?
&&
rule
.
approvers
.
present?
}
.
sort_by
(
&
:id
)
any_approver_rules
=
any_approver_rules
=
wrapped_rules
.
select
(
&
:any_approver?
)
wrapped_rules
.
select
(
&
:any_approver?
)
...
...
ee/spec/models/approval_state_spec.rb
View file @
1353b579
...
@@ -106,28 +106,6 @@ describe ApprovalState do
...
@@ -106,28 +106,6 @@ describe ApprovalState do
end
end
end
end
context
'when approval rule on the merge request exists'
do
before
do
create
(
:approval_merge_request_rule
,
merge_request:
merge_request
,
users:
approvers
)
end
context
'without approvers'
do
let
(
:approvers
)
{
[]
}
it
'returns false'
do
expect
(
subject
.
approval_rules_overwritten?
).
to
eq
(
false
)
end
end
context
'with approvers'
do
let
(
:approvers
)
{
[
create
(
:user
)]
}
it
'returns true'
do
expect
(
subject
.
approval_rules_overwritten?
).
to
eq
(
true
)
end
end
end
context
'when merge request has any approver rule'
do
context
'when merge request has any approver rule'
do
let!
(
:any_approver_rule
)
{
create
(
:any_approver_rule
,
merge_request:
merge_request
)
}
let!
(
:any_approver_rule
)
{
create
(
:any_approver_rule
,
merge_request:
merge_request
)
}
...
@@ -594,14 +572,10 @@ describe ApprovalState do
...
@@ -594,14 +572,10 @@ describe ApprovalState do
end
end
context
'when there is one approver required'
do
context
'when there is one approver required'
do
let!
(
:rule
)
{
create_rule
(
approvals_required:
1
,
users:
[])
}
let!
(
:any_approver_rule
)
{
create_rule
(
rule_type: :any_approver
,
approvals_required:
1
)
}
let!
(
:rule
)
{
create_rule
(
approvals_required:
1
,
users:
[
author
])
}
context
'when that approver is the MR author'
do
context
'when that approver is the MR author'
do
before
do
project
.
update!
(
approvals_before_merge:
2
)
rule
.
users
<<
author
end
it_behaves_like
'authors self-approval authorization'
it_behaves_like
'authors self-approval authorization'
it_behaves_like
'a MR that all members with write access can approve'
it_behaves_like
'a MR that all members with write access can approve'
...
@@ -610,30 +584,10 @@ describe ApprovalState do
...
@@ -610,30 +584,10 @@ describe ApprovalState do
expect
(
subject
.
can_approve?
(
nil
)).
to
be_falsey
expect
(
subject
.
can_approve?
(
nil
)).
to
be_falsey
end
end
it
'fallback rule is used'
do
expect
(
subject
.
approvals_left
).
to
eq
(
2
)
end
it
'is not approved'
do
it
'is not approved'
do
expect
(
subject
.
approvals_left
).
to
eq
(
2
)
expect
(
subject
.
approved?
).
to
eq
(
false
)
expect
(
subject
.
approved?
).
to
eq
(
false
)
end
end
context
'with project approval rule'
do
before
do
create
(
:approval_project_rule
,
project:
project
,
approvals_required:
1
,
users:
[
approver
])
end
context
'with approvers'
do
let
(
:approver
)
{
create
(
:user
)
}
it
'requires one approval'
do
rule
=
subject
.
wrapped_approval_rules
.
last
.
approval_rule
expect
(
rule
).
to
be_a
(
ApprovalProjectRule
)
expect
(
subject
.
approvers
).
to
eq
([
approver
])
end
end
end
end
end
end
end
...
@@ -1251,14 +1205,10 @@ describe ApprovalState do
...
@@ -1251,14 +1205,10 @@ describe ApprovalState do
end
end
context
'when there is one approver required'
do
context
'when there is one approver required'
do
let!
(
:rule
)
{
create_rule
(
approvals_required:
1
,
users:
[])
}
let!
(
:rule
)
{
create_rule
(
approvals_required:
1
,
users:
[
author
])
}
let!
(
:any_approver_rule
)
{
create_rule
(
rule_type: :any_approver
,
approvals_required:
1
)
}
context
'when that approver is the MR author'
do
context
'when that approver is the MR author'
do
before
do
project
.
update!
(
approvals_before_merge:
1
)
rule
.
users
<<
author
end
it_behaves_like
'authors self-approval authorization'
it_behaves_like
'authors self-approval authorization'
it_behaves_like
'a MR that all members with write access can approve'
it_behaves_like
'a MR that all members with write access can approve'
...
...
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