Use usual method to retrieve CI/CD stage statuses
This commit is contained in:
parent
32d0983a4e
commit
1066d8ba77
|
@ -10,7 +10,7 @@ module Ci
|
|||
belongs_to :project
|
||||
belongs_to :pipeline
|
||||
|
||||
has_many :commit_statuses, foreign_key: :stage_id
|
||||
has_many :statuses, class_name: 'CommitStatus', foreign_key: :stage_id
|
||||
has_many :builds, foreign_key: :stage_id
|
||||
|
||||
validates :project, presence: true, unless: :importing?
|
||||
|
@ -50,7 +50,7 @@ module Ci
|
|||
|
||||
def update_status
|
||||
retry_optimistic_lock(self) do
|
||||
case commit_statuses.latest.status
|
||||
case statuses.latest.status
|
||||
when 'pending' then enqueue
|
||||
when 'running' then run
|
||||
when 'success' then succeed
|
||||
|
|
|
@ -17,7 +17,7 @@ FactoryGirl.define do
|
|||
end
|
||||
|
||||
factory :ci_stage_entity, class: Ci::Stage do
|
||||
project factory: :empty_project
|
||||
project factory: :project
|
||||
pipeline factory: :ci_empty_pipeline
|
||||
|
||||
name 'test'
|
||||
|
|
|
@ -119,7 +119,7 @@ pipeline_variables:
|
|||
stages:
|
||||
- project
|
||||
- pipeline
|
||||
- commit_statuses
|
||||
- statuses
|
||||
- builds
|
||||
statuses:
|
||||
- project
|
||||
|
|
|
@ -9,9 +9,9 @@ describe Ci::Stage, :models do
|
|||
create(:commit_status, stage_id: stage.id)
|
||||
end
|
||||
|
||||
describe '#commit_statuses' do
|
||||
describe '#statuses' do
|
||||
it 'returns all commit statuses' do
|
||||
expect(stage.commit_statuses.count).to be 2
|
||||
expect(stage.statuses.count).to be 2
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue