summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-02-16 19:29:11 -0200
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-02-20 12:10:26 -0200
commit49cd19652ade0eb81126caa590461e8340d63d26 (patch)
treee696dd625da985dbda5571bfbda74c20423f9630 /spec/services
parent917081fe9dd3da2995faf8f5555ed120ec4c4ea5 (diff)
downloadgitlab-ce-49cd19652ade0eb81126caa590461e8340d63d26.tar.gz
Mark pending tasks for the note author as done when he left a note
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/notes/post_process_service_spec.rb1
-rw-r--r--spec/services/task_service_spec.rb43
2 files changed, 40 insertions, 4 deletions
diff --git a/spec/services/notes/post_process_service_spec.rb b/spec/services/notes/post_process_service_spec.rb
index 1a3f339bd64..9489b8c6336 100644
--- a/spec/services/notes/post_process_service_spec.rb
+++ b/spec/services/notes/post_process_service_spec.rb
@@ -20,6 +20,7 @@ describe Notes::PostProcessService, services: true do
it do
expect(project).to receive(:execute_hooks)
expect(project).to receive(:execute_services)
+ expect_any_instance_of(TaskService).to receive(:new_note).with(@note)
Notes::PostProcessService.new(@note).execute
end
end
diff --git a/spec/services/task_service_spec.rb b/spec/services/task_service_spec.rb
index 04735900e25..2fd75d10b6c 100644
--- a/spec/services/task_service_spec.rb
+++ b/spec/services/task_service_spec.rb
@@ -43,8 +43,8 @@ describe TaskService, services: true do
it 'marks related pending tasks to the target for the user as done' do
service.close_issue(assigned_issue, john_doe)
- expect(first_pending_task.reload.done?).to eq true
- expect(second_pending_task.reload.done?).to eq true
+ expect(first_pending_task.reload).to be_done
+ expect(second_pending_task.reload).to be_done
end
end
@@ -75,8 +75,43 @@ describe TaskService, services: true do
it 'marks related pending tasks to the target for the user as done' do
service.mark_as_done(assigned_issue, john_doe)
- expect(first_pending_task.reload.done?).to eq true
- expect(second_pending_task.reload.done?).to eq true
+ expect(first_pending_task.reload).to be_done
+ expect(second_pending_task.reload).to be_done
+ end
+ end
+
+ describe '#new_note' do
+ let!(:first_pending_task) do
+ create(:pending_assigned_task, user: john_doe, project: project, target: assigned_issue, author: author)
+ end
+
+ let!(:second_pending_task) do
+ create(:pending_assigned_task, user: john_doe, project: project, target: assigned_issue, author: author)
+ end
+
+ let(:note) { create(:note, project: project, noteable: assigned_issue, author: john_doe) }
+ let(:award_note) { create(:note, :award, project: project, noteable: assigned_issue, author: john_doe, note: 'thumbsup') }
+ let(:system_note) { create(:system_note, project: project, noteable: assigned_issue) }
+
+ it 'mark related pending tasks to the noteable for the note author as done' do
+ service.new_note(note)
+
+ expect(first_pending_task.reload).to be_done
+ expect(second_pending_task.reload).to be_done
+ end
+
+ it 'mark related pending tasks to the noteable for the award note author as done' do
+ service.new_note(award_note)
+
+ expect(first_pending_task.reload).to be_done
+ expect(second_pending_task.reload).to be_done
+ end
+
+ it 'does not mark related pending tasks it is a system note' do
+ service.new_note(system_note)
+
+ expect(first_pending_task.reload).to be_pending
+ expect(second_pending_task.reload).to be_pending
end
end
end