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, #params

Instance Method Summary collapse

Methods inherited from BaseProjectService

#initialize

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods inherited from BaseContainerService

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

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

    create_due_date_note if issuable.previous_changes.include?('due_date')
    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