Commit c7a7ef04 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Use a new stage_id reference to a persisted stage

parent 9c10683b
......@@ -43,9 +43,7 @@ class CommitStatus < ActiveRecord::Base
# `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
belongs_to :stage_entity, foreign_key: :stage_id, class_name: 'Ci::Stage'
state_machine :status do
event :enqueue do
......
......@@ -409,9 +409,10 @@ describe CommitStatus, :models do
end
describe '#stage_entity' do
let!(:stage) do
create(:ci_stage_entity, pipeline: commit_status.pipeline,
name: commit_status.stage)
let(:stage) { create(:ci_stage_entity) }
let(:commit_status) do
create(:commit_status, stage_id: stage.id)
end
it 'has a correct association with persisted stage' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment