summaryrefslogtreecommitdiff
path: root/spec/migrations
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-02-06 09:58:50 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-02-06 09:58:50 +0100
commite178135d57a9b06788878721316d00efa77ac4a4 (patch)
tree6411d3ab00532a22d41091cdc70168e305a0008f /spec/migrations
parent066d4deaed3d8698a9d1decd138871528cecc4af (diff)
downloadgitlab-ce-e178135d57a9b06788878721316d00efa77ac4a4.tar.gz
Add more specs for unique stages index migration
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/remove_redundant_pipeline_stages_spec.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/spec/migrations/remove_redundant_pipeline_stages_spec.rb b/spec/migrations/remove_redundant_pipeline_stages_spec.rb
index b2b6446f2c8..8325f986594 100644
--- a/spec/migrations/remove_redundant_pipeline_stages_spec.rb
+++ b/spec/migrations/remove_redundant_pipeline_stages_spec.rb
@@ -37,12 +37,23 @@ describe RemoveRedundantPipelineStages, :migration do
expect(builds.all.pluck(:stage_id).compact).to eq [102]
end
- it 'retries when duplicated stages are being created during migration' do
+ it 'retries when incorrectly added index exception is caught' do
+ allow_any_instance_of(described_class)
+ .to receive(:remove_redundant_pipeline_stages!)
+
+ expect_any_instance_of(described_class)
+ .to receive(:remove_outdated_index!)
+ .exactly(100).times.and_call_original
+
+ expect { migrate! }
+ .to raise_error StandardError, /Failed to add an unique index/
+ end
+
+ it 'does not retry when unknown exception is being raised' 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).to receive(:remove_redundant_pipeline_stages!).once
+ allow(subject).to receive(:add_unique_index!).and_raise(StandardError)
- expect { subject.up(attempts: 3) }.to raise_error ActiveRecord::RecordNotUnique
+ expect { subject.up(attempts: 3) }.to raise_error StandardError
end
end