Notify the user who set auto-merge when a build fails

This commit is contained in:
twonegatives 2016-12-13 00:55:33 +03:00
parent b1120fc3e7
commit f14228f0f2
4 changed files with 21 additions and 7 deletions

View File

@ -11,7 +11,7 @@ module TodosHelper
case todo.action
when Todo::ASSIGNED then 'assigned you'
when Todo::MENTIONED then 'mentioned you on'
when Todo::BUILD_FAILED then 'The build failed for your'
when Todo::BUILD_FAILED then 'The build failed for'
when Todo::MARKED then 'added a todo for'
when Todo::APPROVAL_REQUIRED then 'set you as an approver for'
end

View File

@ -98,10 +98,12 @@ class TodoService
# When a build fails on the HEAD of a merge request we should:
#
# * create a todo for that user to fix it
# * create a todo for author of MR to fix it
# * create a todo for merge_user to keep an eye on it
#
def merge_request_build_failed(merge_request)
create_build_failed_todo(merge_request)
create_build_failed_todo(merge_request, merge_request.author)
create_build_failed_todo(merge_request, merge_request.merge_user) if merge_request.merge_when_build_succeeds?
end
# When a new commit is pushed to a merge request we should:
@ -115,9 +117,11 @@ class TodoService
# When a build is retried to a merge request we should:
#
# * mark all pending todos related to the merge request for the author as done
# * mark all pending todos related to the merge request for the merge_user as done
#
def merge_request_build_retried(merge_request)
mark_pending_todos_as_done(merge_request, merge_request.author)
mark_pending_todos_as_done(merge_request, merge_request.merge_user) if merge_request.merge_when_build_succeeds?
end
# When create a note we should:
@ -236,10 +240,9 @@ class TodoService
create_todos(mentioned_users, attributes)
end
def create_build_failed_todo(merge_request)
author = merge_request.author
attributes = attributes_for_todo(merge_request.project, merge_request, author, Todo::BUILD_FAILED)
create_todos(author, attributes)
def create_build_failed_todo(merge_request, todo_author)
attributes = attributes_for_todo(merge_request.project, merge_request, todo_author, Todo::BUILD_FAILED)
create_todos(todo_author, attributes)
end
def attributes_for_target(target)

View File

@ -0,0 +1,4 @@
---
title: Create a TODO for user who set auto-merge when a build fails
merge_request:
author:

View File

@ -469,6 +469,13 @@ describe TodoService, services: true do
should_create_todo(user: author, target: mr_unassigned, action: Todo::BUILD_FAILED)
end
it 'creates a pending todo for merge_user' do
mr_unassigned.update(merge_when_build_succeeds: true, merge_user: admin)
service.merge_request_build_failed(mr_unassigned)
should_create_todo(user: admin, author: admin, target: mr_unassigned, action: Todo::BUILD_FAILED)
end
end
describe '#merge_request_push' do