Commit d3814ad6 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Adds some specs for stage optimistic locking

parent 0aefb516
...@@ -220,6 +220,7 @@ Ci::Stage: ...@@ -220,6 +220,7 @@ Ci::Stage:
- id - id
- name - name
- status - status
- lock_version
- project_id - project_id
- pipeline_id - pipeline_id
- created_at - created_at
......
...@@ -54,7 +54,26 @@ describe Ci::Stage, :models do ...@@ -54,7 +54,26 @@ describe Ci::Stage, :models do
end end
end end
context 'when stage is skipped' do
it 'updates status to skipped' do
expect { stage.update! }
.to change { stage.reload.status }
.to 'skipped'
end
end
context 'when stage object is locked' do context 'when stage object is locked' do
before do
create(:ci_build, :failed, stage_id: stage.id)
end
it 'retries a lock to update a stage status' do
stage.lock_version = 100
stage.update!
expect(stage.reload).to be_failed
end
end end
end end
end end
...@@ -22,7 +22,7 @@ describe Ci::RetryBuildService, :services do ...@@ -22,7 +22,7 @@ describe Ci::RetryBuildService, :services do
%i[type lock_version target_url base_tags %i[type lock_version target_url base_tags
commit_id deployments erased_by_id last_deployment project_id commit_id deployments erased_by_id last_deployment project_id
runner_id tag_taggings taggings tags trigger_request_id runner_id tag_taggings taggings tags trigger_request_id
user_id auto_canceled_by_id retried].freeze user_id auto_canceled_by_id retried stage_entity].freeze
shared_examples 'build duplication' do shared_examples 'build duplication' do
let(:stage) do let(: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