diff options
author | Oswaldo Ferreira <oswluizf@gmail.com> | 2016-10-13 12:26:44 -0300 |
---|---|---|
committer | Oswaldo Ferreira <oswluizf@gmail.com> | 2016-11-11 22:54:11 -0200 |
commit | d48d879ef5e0b1517c43bef27f584655535259c8 (patch) | |
tree | 0d0477d0b4f35232fceb8ba83548c29187603caa /spec/workers/new_note_worker_spec.rb | |
parent | 6eeff67c6e03233d4480a55d05d4e0f1a88aef4c (diff) | |
download | gitlab-ce-d48d879ef5e0b1517c43bef27f584655535259c8.tar.gz |
Does not raise error when Note not found when processing NewNoteWorker
- Also remove unnecessary param
Diffstat (limited to 'spec/workers/new_note_worker_spec.rb')
-rw-r--r-- | spec/workers/new_note_worker_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/workers/new_note_worker_spec.rb b/spec/workers/new_note_worker_spec.rb new file mode 100644 index 00000000000..8fdbb35afd0 --- /dev/null +++ b/spec/workers/new_note_worker_spec.rb @@ -0,0 +1,49 @@ +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 |