gitlab-org--gitlab-foss/spec/workers/new_note_worker_spec.rb
Douwe Maan 1fe7501b49 Revert "Prefer leading style for Style/DotPosition"
This reverts commit cb10b725c8929b8b4460f89c9d96c773af39ba6b.
2017-02-23 09:33:05 -06:00

49 lines
1.4 KiB
Ruby

require "spec_helper"
describe NewNoteWorker do
context 'when Note found' do
let(:note) { create(:note) }
it "calls NotificationService#new_note" do
expect_any_instance_of(NotificationService).to receive(:new_note).with(note)
described_class.new.perform(note.id)
end
it "calls Notes::PostProcessService#execute" do
notes_post_process_service = double(Notes::PostProcessService)
allow(Notes::PostProcessService).to receive(:new).with(note) { notes_post_process_service }
expect(notes_post_process_service).to receive(:execute)
described_class.new.perform(note.id)
end
end
context 'when Note not found' do
let(:unexistent_note_id) { 999 }
it 'logs NewNoteWorker process skipping' do
expect(Rails.logger).to receive(:error).
with("NewNoteWorker: couldn't find note with ID=999, skipping job")
described_class.new.perform(unexistent_note_id)
end
it 'does not raise errors' do
expect { described_class.new.perform(unexistent_note_id) }.not_to raise_error
end
it "does not call NotificationService#new_note" do
expect_any_instance_of(NotificationService).not_to receive(:new_note)
described_class.new.perform(unexistent_note_id)
end
it "does not call Notes::PostProcessService#execute" do
expect_any_instance_of(Notes::PostProcessService).not_to receive(:execute)
described_class.new.perform(unexistent_note_id)
end
end
end