summaryrefslogtreecommitdiff
path: root/spec/services/notes
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-02-16 20:21:24 -0200
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-02-20 12:10:26 -0200
commit9da03c45c9e313e8adb170ee9933bd94efbf747c (patch)
treeb4c362ce821f62404f67a3bed723f4edbb1283d3 /spec/services/notes
parent49cd19652ade0eb81126caa590461e8340d63d26 (diff)
downloadgitlab-ce-9da03c45c9e313e8adb170ee9933bd94efbf747c.tar.gz
Mark pending tasks for the current user as done when he edit a note
Diffstat (limited to 'spec/services/notes')
-rw-r--r--spec/services/notes/update_service_spec.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/services/notes/update_service_spec.rb b/spec/services/notes/update_service_spec.rb
new file mode 100644
index 00000000000..e6670143951
--- /dev/null
+++ b/spec/services/notes/update_service_spec.rb
@@ -0,0 +1,45 @@
+require 'spec_helper'
+
+describe Notes::UpdateService, services: true do
+ let(:project) { create(:empty_project) }
+ let(:user) { create(:user) }
+ let(:user2) { create(:user) }
+ let(:issue) { create(:issue, project: project) }
+ let(:note) { create(:note, project: project, noteable: issue, author: user, note: 'Old note') }
+
+ before do
+ project.team << [user, :master]
+ project.team << [user2, :developer]
+ end
+
+ describe '#execute' do
+ def update_note(opts)
+ @note = Notes::UpdateService.new(project, user, opts).execute(note)
+ @note.reload
+ end
+
+ context 'task queue' do
+ let!(:task) { create(:pending_assigned_task, user: user, project: project, target: issue, author: user2) }
+
+ context 'when the note change' do
+ before do
+ update_note({ note: 'New note' })
+ end
+
+ it 'marks pending tasks as done' do
+ expect(task.reload).to be_done
+ end
+ end
+
+ context 'when the note does not change' do
+ before do
+ update_note({ note: 'Old note' })
+ end
+
+ it 'keep pending tasks' do
+ expect(task.reload).to be_pending
+ end
+ end
+ end
+ end
+end