BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
eeeb96c9
Commit
eeeb96c9
authored
Sep 28, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change service to be a worker, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6342#note_16118195
parent
9622ef64
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
21 deletions
+19
-21
pipeline.rb
app/models/ci/pipeline.rb
+2
-2
pipelines_email_service.rb
app/models/project_services/pipelines_email_service.rb
+2
-2
send_pipeline_notification_service.rb
app/services/ci/send_pipeline_notification_service.rb
+0
-13
send_pipeline_notification_worker.rb
app/workers/send_pipeline_notification_worker.rb
+9
-0
pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+4
-2
send_pipeline_notification_worker_spec.rb
spec/workers/send_pipeline_notification_worker_spec.rb
+2
-2
No files found.
app/models/ci/pipeline.rb
View file @
eeeb96c9
...
...
@@ -83,8 +83,8 @@ module Ci
end
end
after_transition
any
=>
[
:success
,
:failed
]
do
|
pipeline
,
transition
|
SendPipelineNotification
Service
.
new
(
pipeline
).
execute
after_transition
any
=>
[
:success
,
:failed
]
do
|
pipeline
|
SendPipelineNotification
Worker
.
perform_async
(
pipeline
.
id
)
end
end
...
...
app/models/project_services/pipelines_email_service.rb
View file @
eeeb96c9
...
...
@@ -31,8 +31,8 @@ class PipelinesEmailService < Service
return
unless
all_recipients
.
any?
pipeline
=
Ci
::
Pipeline
.
find
(
data
[
:object_attributes
][
:id
])
Ci
::
SendPipelineNotificationService
.
new
(
pipeline
).
execute
(
all_recipients
)
pipeline
_id
=
data
[
:object_attributes
][
:id
]
SendPipelineNotificationWorker
.
perform_async
(
pipeline_id
,
all_recipients
)
end
def
can_test?
...
...
app/services/ci/send_pipeline_notification_service.rb
deleted
100644 → 0
View file @
9622ef64
module
Ci
class
SendPipelineNotificationService
<
BaseService
attr_reader
:pipeline
def
initialize
(
new_pipeline
)
@pipeline
=
new_pipeline
end
def
execute
(
recipients
=
nil
)
notification_service
.
pipeline_finished
(
pipeline
,
recipients
)
end
end
end
app/workers/send_pipeline_notification_worker.rb
0 → 100644
View file @
eeeb96c9
class
SendPipelineNotificationWorker
include
Sidekiq
::
Worker
def
perform
(
pipeline_id
,
recipients
=
nil
)
pipeline
=
Ci
::
Pipeline
.
find
(
pipeline_id
)
NotificationService
.
new
.
pipeline_finished
(
pipeline
,
recipients
)
end
end
spec/models/ci/pipeline_spec.rb
View file @
eeeb96c9
...
...
@@ -537,8 +537,10 @@ describe Ci::Pipeline, models: true do
before
do
reset_delivered_emails!
pipeline
.
enqueue
pipeline
.
run
perform_enqueued_jobs
do
pipeline
.
enqueue
pipeline
.
run
end
end
shared_examples
'sending a notification'
do
...
...
spec/
services/ci/send_pipeline_notification_service
_spec.rb
→
spec/
workers/send_pipeline_notification_worker
_spec.rb
View file @
eeeb96c9
require
'spec_helper'
describe
Ci
::
SendPipelineNotificationService
,
services:
true
do
describe
SendPipelineNotificationWorker
,
services:
true
do
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
...
...
@@ -23,7 +23,7 @@ describe Ci::SendPipelineNotificationService, services: true do
shared_examples
'sending emails'
do
it
'sends emails'
do
perform_enqueued_jobs
do
subject
.
execute
subject
.
perform
(
pipeline
.
id
)
end
expected_receivers
=
[
pusher
,
watcher
].
uniq
.
sort_by
(
&
:email
)
...
...
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