Class: MergeRequests::AssignIssuesService

Inherits:
BaseService show all
Defined in:
app/services/merge_requests/assign_issues_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#cancel_review_app_jobs!, #cleanup_environments, #create_note, #execute_hooks, #hook_data, #inspect, #source_project, #target_project

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods included from AssignsMergeParams

#assign_allowed_merge_params, included

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Instance Method Details

#assignable_issuesObject


5
6
7
8
9
10
11
12
13
14
15
# File 'app/services/merge_requests/assign_issues_service.rb', line 5

def assignable_issues
  @assignable_issues ||= begin
    if current_user == merge_request.author
      closes_issues.select do |issue|
        !issue.is_a?(ExternalIssue) && !issue.assignees.present? && can?(current_user, :admin_issue, issue)
      end
    else
      []
    end
  end
end

#executeObject


17
18
19
20
21
22
23
24
25
# File 'app/services/merge_requests/assign_issues_service.rb', line 17

def execute
  assignable_issues.each do |issue|
    Issues::UpdateService.new(issue.project, current_user, assignee_ids: [current_user.id]).execute(issue)
  end

  {
    count: assignable_issues.count
  }
end