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

42 lines
1.2 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2019-02-15 15:39:39 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe RemoteMirrorNotificationWorker, :mailer do
2020-04-08 14:13:33 +05:30
let_it_be(:project) { create(:project, :repository, :remote_mirror) }
let_it_be(:mirror) { project.remote_mirrors.first }
2019-02-15 15:39:39 +05:30
2020-11-24 15:15:51 +05:30
describe '#perform' do
2019-02-15 15:39:39 +05:30
it 'calls NotificationService#remote_mirror_update_failed when the mirror exists' do
mirror.update_column(:last_error, "There was a problem fetching")
expect(NotificationService).to receive_message_chain(:new, :remote_mirror_update_failed)
subject.perform(mirror.id)
expect(mirror.reload.error_notification_sent?).to be_truthy
end
it 'does nothing when the mirror has no errors' do
expect(NotificationService).not_to receive(:new)
subject.perform(mirror.id)
end
it 'does nothing when the mirror does not exist' do
expect(NotificationService).not_to receive(:new)
2020-04-22 19:07:51 +05:30
subject.perform(non_existing_record_id)
2019-02-15 15:39:39 +05:30
end
it 'does nothing when a notification has already been sent' do
mirror.update_columns(last_error: "There was a problem fetching",
error_notification_sent: true)
expect(NotificationService).not_to receive(:new)
subject.perform(mirror.id)
end
end
end