diff options
author | Oswaldo Ferreira <oswluizf@gmail.com> | 2016-10-13 18:26:44 +0300 |
---|---|---|
committer | Oswaldo Ferreira <oswluizf@gmail.com> | 2016-11-12 03:54:11 +0300 |
commit | d48d879ef5e0b1517c43bef27f584655535259c8 (patch) | |
tree | 0d0477d0b4f35232fceb8ba83548c29187603caa /spec/services/notes/create_service_spec.rb | |
parent | 6eeff67c6e03233d4480a55d05d4e0f1a88aef4c (diff) |
Does not raise error when Note not found when processing NewNoteWorker
- Also remove unnecessary param
Diffstat (limited to 'spec/services/notes/create_service_spec.rb')
-rw-r--r-- | spec/services/notes/create_service_spec.rb | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb index 93885c84dc3..25804696d2e 100644 --- a/spec/services/notes/create_service_spec.rb +++ b/spec/services/notes/create_service_spec.rb @@ -14,12 +14,41 @@ describe Notes::CreateService, services: true do end context "valid params" do - before do - @note = Notes::CreateService.new(project, user, opts).execute + it 'returns a valid note' do + note = Notes::CreateService.new(project, user, opts).execute + + expect(note).to be_valid + end + + it 'returns a persisted note' do + note = Notes::CreateService.new(project, user, opts).execute + + expect(note).to be_persisted + end + + it 'note has valid content' do + note = Notes::CreateService.new(project, user, opts).execute + + expect(note.note).to eq(opts[:note]) end - it { expect(@note).to be_valid } - it { expect(@note.note).to eq(opts[:note]) } + it 'TodoService#new_note is called' do + note = build(:note) + allow(project).to receive_message_chain(:notes, :new).with(opts) { note } + + expect_any_instance_of(TodoService).to receive(:new_note).with(note, user) + + Notes::CreateService.new(project, user, opts).execute + end + + it 'enqueues NewNoteWorker' do + note = build(:note, id: 999) + allow(project).to receive_message_chain(:notes, :new).with(opts) { note } + + expect(NewNoteWorker).to receive(:perform_async).with(note.id) + + Notes::CreateService.new(project, user, opts).execute + end end describe 'note with commands' do |