debian-mirror-gitlab/spec/workers/pipeline_notification_worker_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
1.3 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe PipelineNotificationWorker, :mailer do
2020-04-08 14:13:33 +05:30
let_it_be(:pipeline) { create(:ci_pipeline) }
2017-08-17 22:00:37 +05:30
describe '#execute' do
it 'calls NotificationService#pipeline_finished when the pipeline exists' do
2020-04-08 14:13:33 +05:30
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)
2017-08-17 22:00:37 +05:30
2020-04-08 14:13:33 +05:30
subject.perform(pipeline.id, ref_status: 'success', recipients: ['test@gitlab.com'])
2017-08-17 22:00:37 +05:30
end
it 'does nothing when the pipeline does not exist' do
expect(NotificationService).not_to receive(:new)
2020-04-22 19:07:51 +05:30
subject.perform(non_existing_record_id)
2017-08-17 22:00:37 +05:30
end
2021-10-27 15:23:28 +05:30
2022-07-23 23:45:48 +05:30
context 'when the user is blocked' do
before do
expect_next_found_instance_of(Ci::Pipeline) do |pipeline|
allow(pipeline).to receive(:user) { build(:user, :blocked) }
end
end
it 'does nothing' do
expect(NotificationService).not_to receive(:new)
subject.perform(pipeline.id)
end
end
2021-10-27 15:23:28 +05:30
it_behaves_like 'worker with data consistency',
described_class,
data_consistency: :delayed
2017-08-17 22:00:37 +05:30
end
end