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
382ab43b
Commit
382ab43b
authored
Jul 01, 2020
by
Kerri Miller
Committed by
Igor Drozdov
Jul 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Filter by section to support sectional codeowners
parent
1de11e5d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
3 deletions
+11
-3
ee/app/models/approval_merge_request_rule.rb
ee/app/models/approval_merge_request_rule.rb
+1
-2
ee/spec/factories/approval_rules.rb
ee/spec/factories/approval_rules.rb
+1
-0
ee/spec/models/approval_merge_request_rule_spec.rb
ee/spec/models/approval_merge_request_rule_spec.rb
+8
-0
ee/spec/services/ee/merge_requests/refresh_service_spec.rb
ee/spec/services/ee/merge_requests/refresh_service_spec.rb
+1
-1
No files found.
ee/app/models/approval_merge_request_rule.rb
View file @
382ab43b
...
...
@@ -66,8 +66,7 @@ class ApprovalMergeRequestRule < ApplicationRecord
scope
:for_checks_that_can_be_refreshed
,
->
{
license_compliance
.
open_merge_requests
.
with_head_pipeline
}
def
self
.
find_or_create_code_owner_rule
(
merge_request
,
entry
)
merge_request
.
approval_rules
.
code_owner
.
where
(
name:
entry
.
pattern
).
first_or_create
do
|
rule
|
rule
.
section
=
entry
.
section
merge_request
.
approval_rules
.
code_owner
.
where
(
name:
entry
.
pattern
).
where
(
section:
entry
.
section
).
first_or_create
do
|
rule
|
rule
.
rule_type
=
:code_owner
rule
.
code_owner
=
true
# deprecated, replaced with `rule_type: :code_owner`
end
...
...
ee/spec/factories/approval_rules.rb
View file @
382ab43b
...
...
@@ -11,6 +11,7 @@ FactoryBot.define do
rule_type
{
:code_owner
}
code_owner
{
true
}
# deprecated, replaced with `rule_type: :code_owner`
sequence
(
:name
)
{
|
n
|
"*-
#{
n
}
.js"
}
section
{
Gitlab
::
CodeOwners
::
Entry
::
DEFAULT_SECTION
}
end
factory
:report_approver_rule
,
parent: :approval_merge_request_rule
do
...
...
ee/spec/models/approval_merge_request_rule_spec.rb
View file @
382ab43b
...
...
@@ -169,6 +169,14 @@ RSpec.describe ApprovalMergeRequestRule do
it
'finds the existing rule'
do
expect
(
rule
).
to
eq
(
existing_code_owner_rule
)
end
context
"when the existing rule matches name but not section"
do
let
(
:entry
)
{
Gitlab
::
CodeOwners
::
Entry
.
new
(
"*.rb"
,
"@user"
,
"example_section"
)
}
it
"creates a new rule"
do
expect
(
rule
).
not_to
eq
(
existing_code_owner_rule
)
end
end
end
it
'creates a new rule if it does not exist'
do
...
...
ee/spec/services/ee/merge_requests/refresh_service_spec.rb
View file @
382ab43b
...
...
@@ -125,7 +125,7 @@ RSpec.describe MergeRequests::RefreshService do
end
it_behaves_like
'creates an approval rule based on current diff'
do
let
(
:approval_rules_size
)
{
4
}
let
(
:approval_rules_size
)
{
5
}
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