Commit 0f24c922 authored by Sean McGivern's avatar Sean McGivern

Extract EE-specific lines from TodoService

parent 3194b956
...@@ -108,14 +108,6 @@ class TodoService ...@@ -108,14 +108,6 @@ class TodoService
end end
end end
# When new approvers are added for a merge request:
#
# * create a todo for those users to approve the MR
#
def add_merge_request_approvers(merge_request, approvers)
create_approval_required_todos(merge_request, approvers, merge_request.author)
end
# When a new commit is pushed to a merge request we should: # When a new commit is pushed to a merge request we should:
# #
# * mark all pending todos related to the merge request for that user as done # * mark all pending todos related to the merge request for that user as done
...@@ -237,11 +229,6 @@ class TodoService ...@@ -237,11 +229,6 @@ class TodoService
def new_issuable(issuable, author) def new_issuable(issuable, author)
create_assignment_todo(issuable, author) create_assignment_todo(issuable, author)
if issuable.is_a?(MergeRequest)
create_approval_required_todos(issuable, issuable.overall_approvers, author)
end
create_mention_todos(issuable.project, issuable, author) create_mention_todos(issuable.project, issuable, author)
end end
...@@ -287,11 +274,6 @@ class TodoService ...@@ -287,11 +274,6 @@ class TodoService
create_todos(mentioned_users, attributes) create_todos(mentioned_users, attributes)
end end
def create_approval_required_todos(merge_request, approvers, author)
attributes = attributes_for_todo(merge_request.project, merge_request, author, Todo::APPROVAL_REQUIRED)
create_todos(approvers.map(&:user), attributes)
end
def create_build_failed_todo(merge_request, todo_author) def create_build_failed_todo(merge_request, todo_author)
attributes = attributes_for_todo(merge_request.project, merge_request, todo_author, Todo::BUILD_FAILED) attributes = attributes_for_todo(merge_request.project, merge_request, todo_author, Todo::BUILD_FAILED)
create_todos(todo_author, attributes) create_todos(todo_author, attributes)
......
...@@ -2,6 +2,23 @@ module EE ...@@ -2,6 +2,23 @@ module EE
module TodoService module TodoService
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
# When new approvers are added for a merge request:
#
# * create a todo for those users to approve the MR
#
def add_merge_request_approvers(merge_request, approvers)
create_approval_required_todos(merge_request, approvers, merge_request.author)
end
override :new_issuable
def new_issuable(issuable, author)
if issuable.is_a?(MergeRequest)
create_approval_required_todos(issuable, issuable.overall_approvers, author)
end
super
end
def new_epic(epic, current_user) def new_epic(epic, current_user)
create_mention_todos(nil, epic, current_user) create_mention_todos(nil, epic, current_user)
end end
...@@ -10,6 +27,8 @@ module EE ...@@ -10,6 +27,8 @@ module EE
create_mention_todos(nil, epic, current_user, nil, skip_users) create_mention_todos(nil, epic, current_user, nil, skip_users)
end end
private
override :attributes_for_target override :attributes_for_target
def attributes_for_target(target) def attributes_for_target(target)
attributes = super attributes = super
...@@ -20,5 +39,10 @@ module EE ...@@ -20,5 +39,10 @@ module EE
attributes attributes
end end
def create_approval_required_todos(merge_request, approvers, author)
attributes = attributes_for_todo(merge_request.project, merge_request, author, ::Todo::APPROVAL_REQUIRED)
create_todos(approvers.map(&:user), attributes)
end
end end
end end
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