BigW Consortium Gitlab

Commit 7d6538f2 by Grzegorz Bizon

Rename method responsible for updating stage status

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