diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-07-04 17:41:33 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-07-04 17:41:33 +0300 |
commit | b3ee172b4ee6fd22ebf3705edf6762a9dd777cdc (patch) | |
tree | a0dfe7a53af091591a27444ad0f904ae9e75db26 /app/models/commit_status.rb | |
parent | 22d8460b5d9926d7608d23aeb58e20d9035efa92 (diff) |
Add a workaround for a tmp job -> stage relation
We still didn't migrate `ci_builds.stage_id`, so we can't use a
belongs_to association. We also have `ci_builds.stage` string attribute,
that we need to phase out in favor of `ci_stages.name`.
Diffstat (limited to 'app/models/commit_status.rb')
-rw-r--r-- | app/models/commit_status.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 07cec63b939..afdc75f75fb 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -38,6 +38,15 @@ class CommitStatus < ActiveRecord::Base scope :retried_ordered, -> { retried.ordered.includes(project: :namespace) } scope :after_stage, -> (index) { where('stage_idx > ?', index) } + ## + # TODO, we will change this to `belongs_to :stage` when we phase out + # `ci_builds.stage` attribute and migrate `ci_builds.stage_id` reference in + # one of upcoming releases. + # + def stage_entity + Ci::Stage.find_by(pipeline: pipeline, name: stage) + end + state_machine :status do event :enqueue do transition [:created, :skipped, :manual] => :pending |