generic_commit_status.rb 610 Bytes
Newer Older
1 2
# frozen_string_literal: true

3 4 5
class GenericCommitStatus < CommitStatus
  before_validation :set_default_values

6
  validates :target_url, addressable_url: true,
7 8 9
                         length: { maximum: 255 },
                         allow_nil: true

10 11 12 13 14 15
  # GitHub compatible API
  alias_attribute :context, :name

  def set_default_values
    self.context ||= 'default'
    self.stage ||= 'external'
16
    self.stage_idx ||= 1000000
17 18 19 20 21
  end

  def tags
    [:external]
  end
22 23 24 25 26 27

  def detailed_status(current_user)
    Gitlab::Ci::Status::External::Factory
      .new(self, current_user)
      .fabricate!
  end
28
end