system_note_metadata.rb 1.07 KB
Newer Older
1 2
# frozen_string_literal: true

3
class SystemNoteMetadata < ApplicationRecord
4 5 6 7 8 9
  # These notes's action text might contain a reference that is external.
  # We should always force a deep validation upon references that are found
  # in this note type.
  # Other notes can always be safely shown as all its references are
  # in the same project (i.e. with the same permissions)
  TYPES_WITH_CROSS_REFERENCES = %w[
micael.bergeron's avatar
micael.bergeron committed
10 11
    commit cross_reference
    close duplicate
12
    moved merge
13
    label milestone
micael.bergeron's avatar
micael.bergeron committed
14
  ].freeze
15

16
  ICON_TYPES = %w[
17
    commit description merge confidential visible label assignee cross_reference
Ryan Scott's avatar
Ryan Scott committed
18
    title time_tracking branch milestone discussion task moved
19
    opened closed merged duplicate locked unlocked
20
    outdated tag due_date pinned_embed
21 22 23
  ].freeze

  validates :note, presence: true
24
  validates :action, inclusion: { in: :icon_types }, allow_nil: true
25 26

  belongs_to :note
27
  belongs_to :description_version
28 29 30 31

  def icon_types
    ICON_TYPES
  end
32 33 34 35

  def cross_reference_types
    TYPES_WITH_CROSS_REFERENCES
  end
36
end
37 38

SystemNoteMetadata.prepend_if_ee('EE::SystemNoteMetadata')