Class: ServiceDeskSetting

Inherits:
ApplicationRecord show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/models/service_desk_setting.rb

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods inherited from ApplicationRecord

at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order

Instance Method Details

#issue_template_contentObject


12
13
14
15
16
17
18
19
# File 'app/models/service_desk_setting.rb', line 12

def issue_template_content
  strong_memoize(:issue_template_content) do
    next unless issue_template_key.present?

    Gitlab::Template::IssueTemplate.find(issue_template_key, project).content
  rescue ::Gitlab::Template::Finders::RepoTemplateFinder::FileNotFoundError
  end
end

#issue_template_missing?Boolean

Returns:

  • (Boolean)

21
22
23
# File 'app/models/service_desk_setting.rb', line 21

def issue_template_missing?
  issue_template_key.present? && !issue_template_content.present?
end

#valid_issue_templateObject


25
26
27
28
29
# File 'app/models/service_desk_setting.rb', line 25

def valid_issue_template
  if issue_template_missing?
    errors.add(:issue_template_key, 'is empty or does not exist')
  end
end