Class: Issuable::CommonSystemNotesService

Inherits:
BaseProjectService show all
Defined in:
app/services/issuable/common_system_notes_service.rb

Instance Attribute Summary collapse

Attributes inherited from BaseProjectService

#project

Attributes inherited from BaseContainerService

#container, #current_user, #group, #params, #project

Instance Method Summary collapse

Methods inherited from BaseProjectService

#initialize

Methods inherited from BaseContainerService

#group_container?, #initialize, #namespace_container?, #project_container?, #project_group

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?

Constructor Details

This class inherits a constructor from BaseProjectService

Instance Attribute Details

#issuableObject (readonly)

Returns the value of attribute issuable.



5
6
7
# File 'app/services/issuable/common_system_notes_service.rb', line 5

def issuable
  @issuable
end

Instance Method Details

#execute(issuable, old_labels: [], old_milestone: nil, is_update: true) ⇒ Object



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

def execute(issuable, old_labels: [], old_milestone: nil, is_update: true)
  @issuable = issuable

  # We disable touch so that created system notes do not update
  # the noteable's updated_at field
  ApplicationRecord.no_touching do
    if is_update
      if issuable.previous_changes.include?('title')
        create_title_change_note(issuable.previous_changes['title'].first)
      end

      handle_description_change_note

      handle_time_tracking_note if issuable.is_a?(TimeTrackable)
      create_discussion_lock_note if issuable.previous_changes.include?('discussion_locked')
    end

    handle_start_date_or_due_date_change_note
    create_milestone_change_event(old_milestone) if issuable.previous_changes.include?('milestone_id')
    create_labels_note(old_labels) if old_labels && issuable.labels != old_labels
  end
end