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
aaf1e00b
Commit
aaf1e00b
authored
Jan 07, 2019
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix duplicated approvers scenario
Prevents duplicated record.
parent
6864c1f2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
7 deletions
+9
-7
ee/app/models/ee/merge_request.rb
ee/app/models/ee/merge_request.rb
+1
-1
ee/lib/gitlab/background_migration/migrate_approver_to_approval_rules.rb
...ackground_migration/migrate_approver_to_approval_rules.rb
+4
-4
ee/spec/lib/gitlab/background_migration/migrate_approver_to_approval_rules_spec.rb
...ound_migration/migrate_approver_to_approval_rules_spec.rb
+4
-2
No files found.
ee/app/models/ee/merge_request.rb
View file @
aaf1e00b
...
...
@@ -92,7 +92,7 @@ module EE
rule
=
approval_rules
.
code_owner
.
first
rule
||=
approval_rules
.
code_owner
.
create!
(
name:
ApprovalMergeRequestRule
::
DEFAULT_NAME_FOR_CODE_OWNER
)
rule
.
users
=
code_owners
rule
.
users
=
code_owners
.
uniq
end
else
approval_rules
.
code_owner
.
delete_all
...
...
ee/lib/gitlab/background_migration/migrate_approver_to_approval_rules.rb
View file @
aaf1e00b
...
...
@@ -56,11 +56,11 @@ module Gitlab
has_many
:approval_rules
,
class_name:
'ApprovalMergeRequestRule'
def
approver_ids
@approver_ids
||=
Approver
.
where
(
target_type:
'MergeRequest'
,
target_id:
id
).
pluck
(
:user_id
)
@approver_ids
||=
Approver
.
where
(
target_type:
'MergeRequest'
,
target_id:
id
).
pluck
(
'distinct user_id'
)
end
def
approver_group_ids
@approver_group_ids
||=
ApproverGroup
.
where
(
target_type:
'MergeRequest'
,
target_id:
id
).
pluck
(
:group_id
)
@approver_group_ids
||=
ApproverGroup
.
where
(
target_type:
'MergeRequest'
,
target_id:
id
).
pluck
(
'distinct group_id'
)
end
def
sync_code_owners_with_approvers
...
...
@@ -78,11 +78,11 @@ module Gitlab
has_many
:approval_rules
,
class_name:
'ApprovalProjectRule'
def
approver_ids
@approver_ids
||=
Approver
.
where
(
target_type:
'Project'
,
target_id:
id
).
pluck
(
:user_id
)
@approver_ids
||=
Approver
.
where
(
target_type:
'Project'
,
target_id:
id
).
pluck
(
'distinct user_id'
)
end
def
approver_group_ids
@approver_group_ids
||=
ApproverGroup
.
where
(
target_type:
'Project'
,
target_id:
id
).
pluck
(
:group_id
)
@approver_group_ids
||=
ApproverGroup
.
where
(
target_type:
'Project'
,
target_id:
id
).
pluck
(
'distinct group_id'
)
end
end
...
...
ee/spec/lib/gitlab/background_migration/migrate_approver_to_approval_rules_spec.rb
View file @
aaf1e00b
...
...
@@ -86,8 +86,10 @@ describe Gitlab::BackgroundMigration::MigrateApproverToApprovalRules do
context
'when project rule is present'
do
let!
(
:project_rule
)
{
create
(
:approval_project_rule
,
project:
target
.
target_project
)
}
it
"sets MR rule's source to project rule"
do
create_member_in
(
create
(
:user
),
:old_schema
)
it
"sets MR rule's source to project rule without duplication"
do
user
=
create
(
:user
)
create_member_in
(
user
,
:old_schema
)
create_member_in
(
user
,
:old_schema
)
described_class
.
new
.
perform
(
target_type
,
target
.
id
)
...
...
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