Class: Issues::UpdateService

Inherits:
BaseService show all
Defined in:
app/services/issues/update_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#hook_data

Methods inherited from BaseService

#abilities, #can?, #deny_visibility_level, #event_service, #initialize, #log_info, #notification_service, #repository, #system_hook_service, #todo_service

Methods included from Gitlab::CurrentSettings

#current_application_settings, #fake_application_settings

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#close_serviceObject


37
38
39
# File 'app/services/issues/update_service.rb', line 37

def close_service
  Issues::CloseService
end

#execute(issue) ⇒ Object


3
4
5
# File 'app/services/issues/update_service.rb', line 3

def execute(issue)
  update(issue)
end

#handle_changes(issue, old_labels: []) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/services/issues/update_service.rb', line 7

def handle_changes(issue, old_labels: [])
  if has_changes?(issue, old_labels: old_labels)
    todo_service.mark_pending_todos_as_done(issue, current_user)
  end

  if issue.previous_changes.include?('title') ||
     issue.previous_changes.include?('description')
    todo_service.update_issue(issue, current_user)
  end

  if issue.previous_changes.include?('milestone_id')
    create_milestone_note(issue)
  end

  if issue.previous_changes.include?('assignee_id')
    create_assignee_note(issue)
    notification_service.reassigned_issue(issue, current_user)
    todo_service.reassigned_issue(issue, current_user)
  end

  added_labels = issue.labels - old_labels
  if added_labels.present?
    notification_service.relabeled_issue(issue, added_labels, current_user)
  end
end

#reopen_serviceObject


33
34
35
# File 'app/services/issues/update_service.rb', line 33

def reopen_service
  Issues::ReopenService
end