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
c5da4406
Commit
c5da4406
authored
Apr 22, 2020
by
Kerri Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use an Entry obj instead of Struct
parent
d198605c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
6 deletions
+5
-6
ee/lib/ee/gitlab/background_migration/migrate_approver_to_approval_rules.rb
...ackground_migration/migrate_approver_to_approval_rules.rb
+1
-1
ee/spec/models/approval_merge_request_rule_spec.rb
ee/spec/models/approval_merge_request_rule_spec.rb
+4
-5
No files found.
ee/lib/ee/gitlab/background_migration/migrate_approver_to_approval_rules.rb
View file @
c5da4406
...
...
@@ -130,7 +130,7 @@ module EE
rule
=
approval_rules
.
code_owner
.
first
rule
||=
ApprovalMergeRequestRule
.
find_or_create_code_owner_rule
(
self
,
Struct
.
new
(
:pattern
,
:owner_line
).
new
(
"Code Owner"
)
::
Gitlab
::
CodeOwners
::
Entry
.
new
(
"Code Owner"
,
owners
)
)
rule
.
users
=
owners
.
uniq
...
...
ee/spec/models/approval_merge_request_rule_spec.rb
View file @
c5da4406
...
...
@@ -156,17 +156,16 @@ describe ApprovalMergeRequestRule do
describe
'.find_or_create_code_owner_rule'
do
let!
(
:existing_code_owner_rule
)
{
create
(
:code_owner_rule
,
name:
'*.rb'
,
merge_request:
merge_request
)
}
let
(
:entry
)
{
Struct
.
new
(
:pattern
,
:owner_line
).
new
}
it
'finds an existing rule'
do
entry
.
pattern
=
"*.rb"
entry
=
Gitlab
::
CodeOwners
::
Entry
.
new
(
"*.rb"
,
"@user"
)
expect
(
described_class
.
find_or_create_code_owner_rule
(
merge_request
,
entry
))
.
to
eq
(
existing_code_owner_rule
)
end
it
'creates a new rule if it does not exist'
do
entry
.
pattern
=
"*.js"
entry
=
Gitlab
::
CodeOwners
::
Entry
.
new
(
"*.js"
,
"@user"
)
expect
{
described_class
.
find_or_create_code_owner_rule
(
merge_request
,
entry
)
}
.
to
change
{
merge_request
.
approval_rules
.
matching_pattern
(
'*.js'
).
count
}.
by
(
1
)
...
...
@@ -176,7 +175,7 @@ describe ApprovalMergeRequestRule do
deprecated_code_owner_rule
=
create
(
:code_owner_rule
,
name:
'*.md'
,
merge_request:
merge_request
)
deprecated_code_owner_rule
.
update_column
(
:rule_type
,
described_class
.
rule_types
[
:regular
])
entry
.
pattern
=
"*.md"
entry
=
Gitlab
::
CodeOwners
::
Entry
.
new
(
"*.md"
,
"@user"
)
expect
(
described_class
.
find_or_create_code_owner_rule
(
merge_request
,
entry
))
.
to
eq
(
deprecated_code_owner_rule
)
...
...
@@ -186,7 +185,7 @@ describe ApprovalMergeRequestRule do
expect
(
described_class
).
to
receive
(
:code_owner
).
and_raise
(
ActiveRecord
::
RecordNotUnique
)
allow
(
described_class
).
to
receive
(
:code_owner
).
and_call_original
entry
.
pattern
=
"*.js"
entry
=
Gitlab
::
CodeOwners
::
Entry
.
new
(
"*.js"
,
"@user"
)
expect
(
described_class
.
find_or_create_code_owner_rule
(
merge_request
,
entry
)).
not_to
be_nil
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