summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-02-16 18:31:40 -0200
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-02-20 12:10:26 -0200
commita56ada0a1e92b9ce919fd75edb6508514d00148a (patch)
tree2f79da2a19248b833470177ad3b7baae27a0de3e /spec/services
parente81061a211fedf9adaca8b053b6633988fdd5644 (diff)
downloadgitlab-ce-a56ada0a1e92b9ce919fd75edb6508514d00148a.tar.gz
Marks pending tasks for an user as done when he close the issue
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/issues/close_service_spec.rb8
-rw-r--r--spec/services/task_service_spec.rb17
2 files changed, 25 insertions, 0 deletions
diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb
index 3a8daf28f5e..7a587a96ddc 100644
--- a/spec/services/issues/close_service_spec.rb
+++ b/spec/services/issues/close_service_spec.rb
@@ -5,6 +5,9 @@ describe Issues::CloseService, services: true do
let(:user2) { create(:user) }
let(:issue) { create(:issue, assignee: user2) }
let(:project) { issue.project }
+ let!(:pending_task) do
+ create(:pending_assigned_task, user: user, project: project, target: issue, author: user2)
+ end
before do
project.team << [user, :master]
@@ -32,6 +35,10 @@ describe Issues::CloseService, services: true do
note = @issue.notes.last
expect(note.note).to include "Status changed to closed"
end
+
+ it 'marks pending tasks as done' do
+ expect(pending_task.reload).to be_done
+ end
end
context "external issue tracker" do
@@ -42,6 +49,7 @@ describe Issues::CloseService, services: true do
it { expect(@issue).to be_valid }
it { expect(@issue).to be_opened }
+ it { expect(pending_task.reload).to be_pending }
end
end
end
diff --git a/spec/services/task_service_spec.rb b/spec/services/task_service_spec.rb
index e8920c59fee..04735900e25 100644
--- a/spec/services/task_service_spec.rb
+++ b/spec/services/task_service_spec.rb
@@ -31,6 +31,23 @@ describe TaskService, services: true do
end
end
+ describe '#close_issue' 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
+
+ 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
+ end
+ end
+
describe '#reassigned_issue' do
it 'creates a pending task for new assignee' do
unassigned_issue.update_attribute(:assignee, john_doe)