summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorKamil TrzciƄski <ayufan@ayufan.eu>2017-12-12 09:40:38 +0000
committerLUKE BENNETT <lbennett@gitlab.com>2017-12-13 13:57:38 +0000
commit2a6a3737ddf2aa0d295e04e2a1f636ee2359b71a (patch)
tree72f2208bb27d2f1f091a8564d81dbef331b08d6b /spec
parent90324cf7618970c6b94b6bcececfe3379f2dacc0 (diff)
downloadgitlab-ce-2a6a3737ddf2aa0d295e04e2a1f636ee2359b71a.tar.gz
Merge branch '41023-activerecord-staleobjecterror--attempted-to-update-a-stale-object--ci-build' into 'master'
Job dropping by MissingDependenciesError should consider StaleObjectError Closes #41023 See merge request gitlab-org/gitlab-ce!15873 (cherry picked from commit 6fff0473e0cf13607fdd49f856821680298113d8) 3494cdfe ActiveRecord::StaleObjectError: Attempted to update a stale object: Ci::Build
Diffstat (limited to 'spec')
-rw-r--r--spec/services/ci/register_job_service_spec.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/services/ci/register_job_service_spec.rb b/spec/services/ci/register_job_service_spec.rb
index 3ee59014b5b..22fb7ed7215 100644
--- a/spec/services/ci/register_job_service_spec.rb
+++ b/spec/services/ci/register_job_service_spec.rb
@@ -307,6 +307,19 @@ module Ci
it_behaves_like 'not pick'
end
+
+ context 'when job object is staled' do
+ let!(:pre_stage_job) { create(:ci_build, :running, pipeline: pipeline, name: 'test', stage_idx: 0) }
+
+ before do
+ allow_any_instance_of(Ci::Build).to receive(:drop!)
+ .and_raise(ActiveRecord::StaleObjectError.new(pending_job, :drop!))
+ end
+
+ it 'does not drop nor pick' do
+ expect(subject).to be_nil
+ end
+ end
end
shared_examples 'validation is not active' do