Commit eeeb96c9 authored by Lin Jen-Shin's avatar Lin Jen-Shin
parent 9622ef64
......@@ -83,8 +83,8 @@ module Ci
end
end
after_transition any => [:success, :failed] do |pipeline, transition|
SendPipelineNotificationService.new(pipeline).execute
after_transition any => [:success, :failed] do |pipeline|
SendPipelineNotificationWorker.perform_async(pipeline.id)
end
end
......
......@@ -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?
......
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
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
......@@ -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
......
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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment