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
ba5c9f62
Commit
ba5c9f62
authored
Apr 14, 2021
by
Kerri Miller
Committed by
Igor Drozdov
Apr 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new MergeRequests::SyncCodeOwnerApprovalRulesWorker
parent
e5dfb288
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
114 additions
and
12 deletions
+114
-12
changelogs/unreleased/325691-add-sync_code_onwers_approval_rules_worker.yml
...sed/325691-add-sync_code_onwers_approval_rules_worker.yml
+5
-0
config/sidekiq_queues.yml
config/sidekiq_queues.yml
+2
-0
ee/app/services/ee/merge_requests/update_service.rb
ee/app/services/ee/merge_requests/update_service.rb
+3
-1
ee/app/workers/all_queues.yml
ee/app/workers/all_queues.yml
+8
-0
ee/app/workers/merge_requests/sync_code_owner_approval_rules_worker.rb
...s/merge_requests/sync_code_owner_approval_rules_worker.rb
+19
-0
ee/spec/services/ee/merge_requests/update_service_spec.rb
ee/spec/services/ee/merge_requests/update_service_spec.rb
+6
-5
ee/spec/services/milestones/destroy_service_spec.rb
ee/spec/services/milestones/destroy_service_spec.rb
+30
-0
ee/spec/workers/merge_requests/sync_code_owner_approval_rules_worker_spec.rb
...ge_requests/sync_code_owner_approval_rules_worker_spec.rb
+33
-0
spec/services/milestones/destroy_service_spec.rb
spec/services/milestones/destroy_service_spec.rb
+8
-6
No files found.
changelogs/unreleased/325691-add-sync_code_onwers_approval_rules_worker.yml
0 → 100644
View file @
ba5c9f62
---
title
:
Add new MergeRequests::SyncCodeOwnerApprovalRulesWorker
merge_request
:
58512
author
:
type
:
performance
config/sidekiq_queues.yml
View file @
ba5c9f62
...
@@ -220,6 +220,8 @@
...
@@ -220,6 +220,8 @@
-
1
-
1
-
-
merge_requests_resolve_todos
-
-
merge_requests_resolve_todos
-
1
-
1
-
-
merge_requests_sync_code_owner_approval_rules
-
1
-
-
metrics_dashboard_prune_old_annotations
-
-
metrics_dashboard_prune_old_annotations
-
1
-
1
-
-
metrics_dashboard_sync_dashboards
-
-
metrics_dashboard_sync_dashboards
...
...
ee/app/services/ee/merge_requests/update_service.rb
View file @
ba5c9f62
...
@@ -39,7 +39,9 @@ module EE
...
@@ -39,7 +39,9 @@ module EE
def
after_update
(
merge_request
)
def
after_update
(
merge_request
)
super
super
::
MergeRequests
::
SyncCodeOwnerApprovalRules
.
new
(
merge_request
).
execute
merge_request
.
run_after_commit
do
::
MergeRequests
::
SyncCodeOwnerApprovalRulesWorker
.
perform_async
(
merge_request
)
end
end
end
override
:create_branch_change_note
override
:create_branch_change_note
...
...
ee/app/workers/all_queues.yml
View file @
ba5c9f62
...
@@ -867,6 +867,14 @@
...
@@ -867,6 +867,14 @@
:weight:
1
:weight:
1
:idempotent:
:idempotent:
:tags: []
:tags: []
-
:name: merge_requests_sync_code_owner_approval_rules
:feature_category: :source_code_management
:has_external_dependencies:
:urgency: :high
:resource_boundary: :unknown
:weight:
1
:idempotent:
true
:tags: []
-
:name: new_epic
-
:name: new_epic
:feature_category: :epics
:feature_category: :epics
:has_external_dependencies:
:has_external_dependencies:
...
...
ee/app/workers/merge_requests/sync_code_owner_approval_rules_worker.rb
0 → 100644
View file @
ba5c9f62
# frozen_string_literal: true
module
MergeRequests
class
SyncCodeOwnerApprovalRulesWorker
include
ApplicationWorker
feature_category
:source_code_management
urgency
:high
deduplicate
:until_executed
idempotent!
def
perform
(
merge_request_id
)
merge_request
=
MergeRequest
.
find_by_id
(
merge_request_id
)
return
unless
merge_request
::
MergeRequests
::
SyncCodeOwnerApprovalRules
.
new
(
merge_request
).
execute
end
end
end
ee/spec/services/ee/merge_requests/update_service_spec.rb
View file @
ba5c9f62
...
@@ -302,12 +302,13 @@ RSpec.describe MergeRequests::UpdateService, :mailer do
...
@@ -302,12 +302,13 @@ RSpec.describe MergeRequests::UpdateService, :mailer do
end
end
end
end
it
'updates code owner approval rules
'
do
context
'when called inside an ActiveRecord transaction
'
do
expect_next_instance_of
(
::
MergeRequests
::
SyncCodeOwnerApprovalRules
)
do
|
instance
|
it
'does not attempt to update code owner approval rules'
do
expect
(
instance
).
to
receive
(
:execut
e
)
allow
(
ActiveRecord
::
Base
.
connection
).
to
receive
(
:transaction_open?
).
and_return
(
tru
e
)
end
expect
(
::
MergeRequests
::
SyncCodeOwnerApprovalRulesWorker
).
not_to
receive
(
:perform_async
)
update_merge_request
(
title:
'Title'
)
update_merge_request
(
title:
'Title'
)
end
end
end
context
'updating reviewers_ids'
do
context
'updating reviewers_ids'
do
...
...
ee/spec/services/milestones/destroy_service_spec.rb
0 → 100644
View file @
ba5c9f62
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Milestones
::
DestroyService
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:milestone
)
{
create
(
:milestone
,
title:
'Milestone v1.0'
,
project:
project
)
}
before
do
project
.
add_maintainer
(
user
)
end
def
service
described_class
.
new
(
project
,
user
,
{})
end
describe
'#execute'
do
context
'with an existing merge request'
do
let!
(
:issue
)
{
create
(
:issue
,
project:
project
,
milestone:
milestone
)
}
let!
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
milestone:
milestone
)
}
it
'manually queues MergeRequests::SyncCodeOwnerApprovalRulesWorker jobs'
do
expect
(
::
MergeRequests
::
SyncCodeOwnerApprovalRulesWorker
).
to
receive
(
:perform_async
)
service
.
execute
(
milestone
)
end
end
end
end
ee/spec/workers/merge_requests/sync_code_owner_approval_rules_worker_spec.rb
0 → 100644
View file @
ba5c9f62
# frozen_string_literal: true
require
"spec_helper"
RSpec
.
describe
MergeRequests
::
SyncCodeOwnerApprovalRulesWorker
do
let_it_be
(
:merge_request
)
{
create
(
:merge_request
)
}
subject
{
described_class
.
new
}
describe
"#perform"
do
it_behaves_like
'an idempotent worker'
do
let
(
:job_args
)
{
[
merge_request
.
id
]
}
end
context
"when merge request is not found"
do
it
"returns without attempting to sync code owner rules"
do
expect
(
MergeRequests
::
SyncCodeOwnerApprovalRules
).
not_to
receive
(
:new
)
subject
.
perform
(
non_existing_record_id
)
end
end
context
"when merge request is found"
do
it
"attempts to sync code owner rules"
do
expect_next_instance_of
(
::
MergeRequests
::
SyncCodeOwnerApprovalRules
)
do
|
instance
|
expect
(
instance
).
to
receive
(
:execute
)
end
subject
.
perform
(
merge_request
.
id
)
end
end
end
end
spec/services/milestones/destroy_service_spec.rb
View file @
ba5c9f62
...
@@ -22,14 +22,16 @@ RSpec.describe Milestones::DestroyService do
...
@@ -22,14 +22,16 @@ RSpec.describe Milestones::DestroyService do
expect
{
milestone
.
reload
}.
to
raise_error
ActiveRecord
::
RecordNotFound
expect
{
milestone
.
reload
}.
to
raise_error
ActiveRecord
::
RecordNotFound
end
end
it
'deletes milestone id from issuables
'
do
context
'with an existing merge request
'
do
issue
=
create
(
:issue
,
project:
project
,
milestone:
milestone
)
let!
(
:issue
)
{
create
(
:issue
,
project:
project
,
milestone:
milestone
)
}
merge_request
=
create
(
:merge_request
,
source_project:
project
,
milestone:
milestone
)
let!
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
milestone:
milestone
)
}
service
.
execute
(
milestone
)
it
'deletes milestone id from issuables'
do
service
.
execute
(
milestone
)
expect
(
issue
.
reload
.
milestone
).
to
be_nil
expect
(
issue
.
reload
.
milestone
).
to
be_nil
expect
(
merge_request
.
reload
.
milestone
).
to
be_nil
expect
(
merge_request
.
reload
.
milestone
).
to
be_nil
end
end
end
it
'logs destroy event'
do
it
'logs destroy event'
do
...
...
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