BigW Consortium Gitlab

Commit 7d6538f2 by Grzegorz Bizon

Rename method responsible for updating stage status

parent f4e01b59
...@@ -50,7 +50,7 @@ module Ci ...@@ -50,7 +50,7 @@ module Ci
end end
end end
def update! def update_status
retry_optimistic_lock(self) do retry_optimistic_lock(self) do
case commit_statuses.latest.status case commit_statuses.latest.status
when 'pending' then enqueue when 'pending' then enqueue
......
...@@ -3,6 +3,8 @@ class StageUpdateWorker ...@@ -3,6 +3,8 @@ class StageUpdateWorker
include PipelineQueue include PipelineQueue
def perform(stage_id) def perform(stage_id)
Ci::Stage.find_by(id: stage_id)&.update! Ci::Stage.find_by(id: stage_id).try do |stage|
stage.update_status
end
end end
end end
...@@ -40,7 +40,7 @@ describe Ci::Stage, :models do ...@@ -40,7 +40,7 @@ describe Ci::Stage, :models do
end end
end end
describe 'update!' do describe 'update_status' do
context 'when stage objects needs to be updated' do context 'when stage objects needs to be updated' do
before do before do
create(:ci_build, :success, stage_id: stage.id) create(:ci_build, :success, stage_id: stage.id)
...@@ -48,7 +48,7 @@ describe Ci::Stage, :models do ...@@ -48,7 +48,7 @@ describe Ci::Stage, :models do
end end
it 'updates stage status correctly' do it 'updates stage status correctly' do
expect { stage.update! } expect { stage.update_status }
.to change { stage.reload.status } .to change { stage.reload.status }
.to 'running' .to 'running'
end end
...@@ -56,7 +56,7 @@ describe Ci::Stage, :models do ...@@ -56,7 +56,7 @@ describe Ci::Stage, :models do
context 'when stage is skipped' do context 'when stage is skipped' do
it 'updates status to skipped' do it 'updates status to skipped' do
expect { stage.update! } expect { stage.update_status }
.to change { stage.reload.status } .to change { stage.reload.status }
.to 'skipped' .to 'skipped'
end end
...@@ -70,7 +70,7 @@ describe Ci::Stage, :models do ...@@ -70,7 +70,7 @@ describe Ci::Stage, :models do
it 'retries a lock to update a stage status' do it 'retries a lock to update a stage status' do
stage.lock_version = 100 stage.lock_version = 100
stage.update! stage.update_status
expect(stage.reload).to be_failed expect(stage.reload).to be_failed
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