Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-02-05 18:22:19 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-02-05 18:22:19 +0300
commitb5c69ce3abed5f8269dee256fca02d3e74b30347 (patch)
tree596f9f41ef145c08c668271e1c5c639b20767360 /spec/migrations
parent5f57c7a5a54d844fb3f8566dd81da3cdde2f3c5b (diff)
Retry migration removing stages in case of duplicates
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/remove_redundant_pipeline_stages_spec.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/migrations/remove_redundant_pipeline_stages_spec.rb b/spec/migrations/remove_redundant_pipeline_stages_spec.rb
index 3bd2a9a2146..b2b6446f2c8 100644
--- a/spec/migrations/remove_redundant_pipeline_stages_spec.rb
+++ b/spec/migrations/remove_redundant_pipeline_stages_spec.rb
@@ -36,4 +36,13 @@ describe RemoveRedundantPipelineStages, :migration do
expect(builds.all.count).to eq 6
expect(builds.all.pluck(:stage_id).compact).to eq [102]
end
+
+ it 'retries when duplicated stages are being created during migration' do
+ allow(subject).to receive(:remove_outdated_index!)
+ expect(subject).to receive(:remove_redundant_pipeline_stages!).exactly(3).times
+ allow(subject).to receive(:add_unique_index!)
+ .and_raise(ActiveRecord::RecordNotUnique.new('Duplicated stages present!'))
+
+ expect { subject.up(attempts: 3) }.to raise_error ActiveRecord::RecordNotUnique
+ end
end