Sha256: d9bb96604e03102532a6897a405c957bd053a1f6d2f5d1516e2c7986061a1057

Contents?: true

Size: 969 Bytes

Versions: 20

Compression:

Stored size: 969 Bytes

Contents

class Status < ActiveRecord::Base
  STATES = %w(pending success failure error).freeze
  enum state: STATES.zip(STATES).to_h

  belongs_to :commit, touch: true

  validates :state, inclusion: {in: STATES, allow_blank: true}, presence: true

  after_create :enable_ci_on_stack
  after_commit :schedule_continuous_delivery, :broadcast_update, on: :create
  after_commit :touch_commit

  delegate :broadcast_update, to: :commit

  def self.replicate_from_github!(github_status)
    find_or_create_by!(
      state: github_status.state,
      description: github_status.description,
      target_url: github_status.rels.try(:[], :target).try(:href),
      context: github_status.context,
      created_at: github_status.created_at,
    )
  end

  def group?
    false
  end

  private

  def enable_ci_on_stack
    commit.stack.enable_ci!
  end

  def touch_commit
    commit.touch
  end

  def schedule_continuous_delivery
    commit.schedule_continuous_delivery
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
shipit-engine-0.5.2 app/models/status.rb
shipit-engine-0.5.1 app/models/status.rb
shipit-engine-0.5.0 app/models/status.rb
shipit-engine-0.4.10 app/models/status.rb
shipit-engine-0.4.9 app/models/status.rb
shipit-engine-0.4.8 app/models/status.rb
shipit-engine-0.4.7 app/models/status.rb
shipit-engine-0.4.6 app/models/status.rb
shipit-engine-0.4.5 app/models/status.rb
shipit-engine-0.4.4 app/models/status.rb
shipit-engine-0.4.3 app/models/status.rb
shipit-engine-0.4.2 app/models/status.rb
shipit-engine-0.4.1 app/models/status.rb
shipit-engine-0.4.0 app/models/status.rb
shipit-engine-0.3.1 app/models/status.rb
shipit-engine-0.3.0 app/models/status.rb
shipit-engine-0.2.3 app/models/status.rb
shipit-engine-0.2.2 app/models/status.rb
shipit-engine-0.2.1 app/models/status.rb
shipit-engine-0.2.0 app/models/status.rb