summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-02-15 10:13:20 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-02-15 10:13:20 +0100
commit6cb5b7c8729151c95d1610f0b2f7255fdac2bdec (patch)
tree860bf81531053a5a97ddc01b183531cfebf2c48f /spec/lib
parent378b2bad11b893fabebc083d000295c1ec499b23 (diff)
downloadgitlab-ce-6cb5b7c8729151c95d1610f0b2f7255fdac2bdec.tar.gz
Recover from unique constraint violation in stages migration
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb b/spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb
index 27cb63848de..e112e9e9e3d 100644
--- a/spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb
+++ b/spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb
@@ -40,4 +40,15 @@ describe Gitlab::BackgroundMigration::MigrateBuildStage, :migration, schema: 201
STATUSES[:failed],
STATUSES[:pending]]
end
+
+ it 'recovers from unique constraint violation only twice' do
+ allow(described_class::Migratable::Stage)
+ .to receive(:find_by).and_return(nil)
+
+ expect(described_class::Migratable::Stage)
+ .to receive(:find_by).exactly(3).times
+
+ expect { described_class.new.perform(1, 6) }
+ .to raise_error ActiveRecord::RecordNotUnique
+ end
end