diff options
author | Toon Claes <toon@gitlab.com> | 2018-11-05 21:26:40 +0100 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2018-11-07 11:29:31 +0100 |
commit | 16116bb148a7582ad39e026459b9fb7572b8936f (patch) | |
tree | 23973515ec833d4cf0525885fb570a3d91a1b7d2 /spec/migrations | |
parent | 149b63272202d78566af59db192c668a8803c910 (diff) | |
download | gitlab-ce-16116bb148a7582ad39e026459b9fb7572b8936f.tar.gz |
Add migration to steal FillStoreUpload
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/steal_fill_store_upload_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/migrations/steal_fill_store_upload_spec.rb b/spec/migrations/steal_fill_store_upload_spec.rb new file mode 100644 index 00000000000..ed809baf2b5 --- /dev/null +++ b/spec/migrations/steal_fill_store_upload_spec.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20181105201455_steal_fill_store_upload.rb') + +describe StealFillStoreUpload, :migration do + let(:uploads) { table(:uploads) } + + describe '#up' do + it 'steals the FillStoreUpload background migration' do + expect(Gitlab::BackgroundMigration).to receive(:steal).with('FillStoreUpload').and_call_original + + migrate! + end + + it 'does not run migration if not needed' do + uploads.create(size: 100.kilobytes, + uploader: 'AvatarUploader', + path: 'uploads/-/system/avatar.jpg', + store: 1) + + expect_any_instance_of(Gitlab::BackgroundMigration::FillStoreUpload).not_to receive(:perform) + + migrate! + end + + it 'ensures all rows are migrated' do + uploads.create(size: 100.kilobytes, + uploader: 'AvatarUploader', + path: 'uploads/-/system/avatar.jpg', + store: nil) + + expect_any_instance_of(Gitlab::BackgroundMigration::FillStoreUpload).to receive(:perform).and_call_original + + expect do + migrate! + end.to change { uploads.where(store: nil).count }.from(1).to(0) + end + end +end |