Commit 1066d8ba authored by Grzegorz Bizon's avatar Grzegorz Bizon

Use usual method to retrieve CI/CD stage statuses

parent 32d0983a
...@@ -10,7 +10,7 @@ module Ci ...@@ -10,7 +10,7 @@ module Ci
belongs_to :project belongs_to :project
belongs_to :pipeline 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 has_many :builds, foreign_key: :stage_id
validates :project, presence: true, unless: :importing? validates :project, presence: true, unless: :importing?
...@@ -50,7 +50,7 @@ module Ci ...@@ -50,7 +50,7 @@ module Ci
def update_status def update_status
retry_optimistic_lock(self) do retry_optimistic_lock(self) do
case commit_statuses.latest.status case statuses.latest.status
when 'pending' then enqueue when 'pending' then enqueue
when 'running' then run when 'running' then run
when 'success' then succeed when 'success' then succeed
......
...@@ -17,7 +17,7 @@ FactoryGirl.define do ...@@ -17,7 +17,7 @@ FactoryGirl.define do
end end
factory :ci_stage_entity, class: Ci::Stage do factory :ci_stage_entity, class: Ci::Stage do
project factory: :empty_project project factory: :project
pipeline factory: :ci_empty_pipeline pipeline factory: :ci_empty_pipeline
name 'test' name 'test'
......
...@@ -119,7 +119,7 @@ pipeline_variables: ...@@ -119,7 +119,7 @@ pipeline_variables:
stages: stages:
- project - project
- pipeline - pipeline
- commit_statuses - statuses
- builds - builds
statuses: statuses:
- project - project
......
...@@ -9,9 +9,9 @@ describe Ci::Stage, :models do ...@@ -9,9 +9,9 @@ describe Ci::Stage, :models do
create(:commit_status, stage_id: stage.id) create(:commit_status, stage_id: stage.id)
end end
describe '#commit_statuses' do describe '#statuses' do
it 'returns all commit 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
end end
......
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