gitlab-org--gitlab-foss/spec/workers/pipeline_notification_worker_spec.rb

25 lines
823 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2016-09-13 13:10:58 -04:00
require 'spec_helper'
describe PipelineNotificationWorker, :mailer do
let_it_be(:pipeline) { create(:ci_pipeline) }
2016-09-13 13:10:58 -04:00
describe '#execute' do
it 'calls NotificationService#pipeline_finished when the pipeline exists' do
notification_service_double = double
expect(notification_service_double).to receive(:pipeline_finished)
.with(pipeline, ref_status: 'success', recipients: ['test@gitlab.com'])
expect(NotificationService).to receive(:new).and_return(notification_service_double)
subject.perform(pipeline.id, ref_status: 'success', recipients: ['test@gitlab.com'])
2016-09-13 13:10:58 -04:00
end
it 'does nothing when the pipeline does not exist' do
expect(NotificationService).not_to receive(:new)
2016-09-14 07:23:04 -04:00
subject.perform(non_existing_record_id)
2016-09-13 13:10:58 -04:00
end
end
end