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 ...@@ -43,9 +43,7 @@ class CommitStatus < ActiveRecord::Base
# `ci_builds.stage` attribute and migrate `ci_builds.stage_id` reference in # `ci_builds.stage` attribute and migrate `ci_builds.stage_id` reference in
# one of upcoming releases. # one of upcoming releases.
# #
def stage_entity belongs_to :stage_entity, foreign_key: :stage_id, class_name: 'Ci::Stage'
Ci::Stage.find_by(pipeline: pipeline, name: stage)
end
state_machine :status do state_machine :status do
event :enqueue do event :enqueue do
......
...@@ -409,9 +409,10 @@ describe CommitStatus, :models do ...@@ -409,9 +409,10 @@ describe CommitStatus, :models do
end end
describe '#stage_entity' do describe '#stage_entity' do
let!(:stage) do let(:stage) { create(:ci_stage_entity) }
create(:ci_stage_entity, pipeline: commit_status.pipeline,
name: commit_status.stage) let(:commit_status) do
create(:commit_status, stage_id: stage.id)
end end
it 'has a correct association with persisted stage' do 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