Sha256: 518862d75a6896eb56507f06840f9480d658e0a93663ad04a6d640ac9b99901c
Contents?: true
Size: 1.04 KB
Versions: 10
Compression:
Stored size: 1.04 KB
Contents
module Shipit class ReleaseStatus < ActiveRecord::Base MAX_DESCRIPTION_LENGTH = 140 include DeferredTouch belongs_to :stack belongs_to :commit belongs_to :user, optional: true deferred_touch stack: :updated_at, commit: :updated_at after_commit :schedule_create_release_statuses, on: :create scope :to_be_created, -> { where(github_id: nil).order(id: :asc) } STATES = %w(pending success failure error).freeze validates :state, presence: true, inclusion: {in: STATES} def create_status_on_github! return true if github_id? update!(github_id: create_status_on_github.id) end private def create_status_on_github Shipit.github.api.create_status( stack.github_repo_name, commit.sha, state, context: stack.release_status_context, target_url: target_url, description: description&.truncate(MAX_DESCRIPTION_LENGTH), ) end def schedule_create_release_statuses CreateReleaseStatusesJob.perform_later(commit) end end end
Version data entries
10 entries across 10 versions & 1 rubygems