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
846d9a39
Commit
846d9a39
authored
Apr 24, 2018
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move approvals notifications to Sidekiq
parent
a5ddd4e6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
12 deletions
+13
-12
ee/app/services/merge_requests/approval_service.rb
ee/app/services/merge_requests/approval_service.rb
+1
-1
ee/app/services/merge_requests/remove_approval_service.rb
ee/app/services/merge_requests/remove_approval_service.rb
+1
-1
ee/spec/services/merge_requests/approval_service_spec.rb
ee/spec/services/merge_requests/approval_service_spec.rb
+2
-3
ee/spec/services/merge_requests/remove_approval_service_spec.rb
...c/services/merge_requests/remove_approval_service_spec.rb
+9
-7
No files found.
ee/app/services/merge_requests/approval_service.rb
View file @
846d9a39
...
...
@@ -10,7 +10,7 @@ module MergeRequests
mark_pending_todos_as_done
(
merge_request
)
if
merge_request
.
approvals_left
.
zero?
notification_service
.
approve_mr
(
merge_request
,
current_user
)
notification_service
.
a
sync
.
a
pprove_mr
(
merge_request
,
current_user
)
execute_hooks
(
merge_request
,
'approved'
)
end
end
...
...
ee/app/services/merge_requests/remove_approval_service.rb
View file @
846d9a39
...
...
@@ -14,7 +14,7 @@ module MergeRequests
create_note
(
merge_request
)
if
currently_approved
notification_service
.
unapprove_mr
(
merge_request
,
current_user
)
notification_service
.
async
.
unapprove_mr
(
merge_request
,
current_user
)
execute_hooks
(
merge_request
,
'unapproved'
)
end
end
...
...
ee/spec/services/merge_requests/approval_service_spec.rb
View file @
846d9a39
...
...
@@ -71,9 +71,8 @@ describe MergeRequests::ApprovalService do
before
do
expect
(
merge_request
).
to
receive
(
:approvals_left
).
and_return
(
0
)
allow
(
service
).
to
receive
(
:notification_service
).
and_return
(
notification_service
)
allow
(
service
).
to
receive
(
:execute_hooks
)
allow
(
notification_service
).
to
receive
(
:approve_mr
)
allow
(
service
).
to
receive
(
:notification_service
).
and_return
(
notification_service
)
end
it
'fires a webhook'
do
...
...
@@ -83,7 +82,7 @@ describe MergeRequests::ApprovalService do
end
it
'sends an email'
do
expect
(
notification_service
).
to
receive
(
:approve_mr
).
with
(
merge_request
,
user
)
expect
(
notification_service
).
to
receive
_message_chain
(
:async
,
:approve_mr
).
with
(
merge_request
,
user
)
service
.
execute
(
merge_request
)
end
...
...
ee/spec/services/merge_requests/remove_approval_service_spec.rb
View file @
846d9a39
...
...
@@ -3,8 +3,8 @@ require 'rails_helper'
describe
MergeRequests
::
RemoveApprovalService
do
describe
'#execute'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:
merge_request
)
{
create
(
:merge_request
)
}
let
(
:
project
)
{
merge_request
.
project
}
let
(
:
project
)
{
create
(
:project
,
approvals_before_merge:
1
)
}
let
(
:
merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
subject
(
:service
)
{
described_class
.
new
(
project
,
user
)
}
...
...
@@ -14,6 +14,8 @@ describe MergeRequests::RemoveApprovalService do
context
'with a user who has approved'
do
before
do
project
.
add_developer
(
create
(
:user
))
merge_request
.
update!
(
approvals_before_merge:
2
)
merge_request
.
approvals
.
create
(
user:
user
)
end
...
...
@@ -30,7 +32,7 @@ describe MergeRequests::RemoveApprovalService do
end
it
'does not send a notification'
do
expect
(
Notify
).
not_to
receive
(
:unapprove_mr
)
expect
(
service
).
not_to
receive
(
:notification_service
)
execute!
end
...
...
@@ -43,16 +45,16 @@ describe MergeRequests::RemoveApprovalService do
end
context
'with an approved merge request'
do
let
(
:notif
y
)
{
Object
.
new
}
let
(
:notif
ication_service
)
{
NotificationService
.
new
}
before
do
merge_request
.
update_attribute
:approvals_before_merge
,
1
merge_request
.
approvals
.
create
(
user:
user
)
allow
(
service
).
to
receive
(
:notification_service
).
and_return
(
notif
y
)
allow
(
service
).
to
receive
(
:notification_service
).
and_return
(
notif
ication_service
)
end
it
'sends a notification'
do
expect
(
notify
).
to
receive
(
:unapprove_mr
)
expect
(
notification_service
).
to
receive_message_chain
(
:async
,
:unapprove_mr
).
with
(
merge_request
,
user
)
execute!
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