Marks pending tasks for an user as done when he merge the MR

parent c86b12bf
......@@ -11,6 +11,7 @@ module MergeRequests
create_merge_event(merge_request, current_user)
create_note(merge_request)
notification_service.merge_mr(merge_request, current_user)
task_service.merge_merge_request(merge_request, current_user)
execute_hooks(merge_request, 'merge')
end
......
......@@ -54,6 +54,14 @@ class TaskService
reassigned_issuable(merge_request, current_user)
end
# When merge a merge request we should:
#
# * mark all pending tasks related to the target for the current user as done
#
def merge_merge_request(merge_request, current_user)
mark_as_done(merge_request, current_user)
end
# When we mark a task as done we should:
#
# * mark all pending tasks related to the target for the user as done
......
......@@ -167,6 +167,23 @@ describe TaskService, services: true do
is_expected_to_not_create_task { service.reassigned_merge_request(mr_assigned, author) }
end
end
describe '#merge_merge_request' do
let!(:first_pending_task) do
create(:pending_assigned_task, user: john_doe, project: project, target: mr_assigned, author: author)
end
let!(:second_pending_task) do
create(:pending_assigned_task, user: john_doe, project: project, target: mr_assigned, author: author)
end
it 'marks related pending tasks to the target for the user as done' do
service.merge_merge_request(mr_assigned, john_doe)
expect(first_pending_task.reload).to be_done
expect(second_pending_task.reload).to be_done
end
end
end
def is_expected_to_create_pending_task(attributes = {})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment