2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
class SystemNoteMetadata < ActiveRecord::Base
|
2018-03-17 18:26:18 +05:30
|
|
|
# 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[
|
|
|
|
commit cross_reference
|
|
|
|
close duplicate
|
2018-11-08 19:23:39 +05:30
|
|
|
moved
|
2018-03-17 18:26:18 +05:30
|
|
|
].freeze
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
ICON_TYPES = %w[
|
|
|
|
commit description merge confidential visible label assignee cross_reference
|
2017-09-10 17:25:29 +05:30
|
|
|
title time_tracking branch milestone discussion task moved
|
2018-03-17 18:26:18 +05:30
|
|
|
opened closed merged duplicate locked unlocked
|
2018-11-20 20:47:30 +05:30
|
|
|
outdated tag due_date
|
2017-08-17 22:00:37 +05:30
|
|
|
].freeze
|
|
|
|
|
|
|
|
validates :note, presence: true
|
2018-10-15 14:42:47 +05:30
|
|
|
validates :action, inclusion: { in: :icon_types }, allow_nil: true
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
belongs_to :note
|
2018-10-15 14:42:47 +05:30
|
|
|
|
|
|
|
def icon_types
|
|
|
|
ICON_TYPES
|
|
|
|
end
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
def cross_reference_types
|
|
|
|
TYPES_WITH_CROSS_REFERENCES
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|