diff options
author | Michael Kozono <mkozono@gmail.com> | 2018-02-08 21:17:00 +0300 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2018-02-12 21:44:15 +0300 |
commit | 67d310a1a640088d497843ec8dce3f16eb285d2d (patch) | |
tree | f2ea00284eaeb700466e98954a0489e27a2ec7e0 /spec/lib/gitlab/background_migration | |
parent | f917fc5d76d39fb17fda2678d5270407595f0128 (diff) |
Fix orphan temp table untracked_files_for_uploads
Diffstat (limited to 'spec/lib/gitlab/background_migration')
-rw-r--r-- | spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb b/spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb index 8189e74646a..6a19e8fdcb8 100644 --- a/spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb +++ b/spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb @@ -8,8 +8,6 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq do before do DatabaseCleaner.clean - - drop_temp_table_if_exists end after do @@ -44,27 +42,6 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq do end end - it 'ensures the untracked_files_for_uploads table exists' do - expect do - described_class.new.perform - end.to change { ActiveRecord::Base.connection.table_exists?(:untracked_files_for_uploads) }.from(false).to(true) - end - - it 'has a path field long enough for really long paths' do - described_class.new.perform - - component = 'a' * 255 - - long_path = [ - 'uploads', - component, # project.full_path - component # filename - ].flatten.join('/') - - record = untracked_files_for_uploads.create!(path: long_path) - expect(record.reload.path.size).to eq(519) - end - context "test bulk insert with ON CONFLICT DO NOTHING or IGNORE" do around do |example| # If this is CI, we use Postgres 9.2 so this whole context should be @@ -90,6 +67,21 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq do UploadService.new(project2, uploaded_file, FileUploader).execute end + it 'has a path field long enough for really long paths' do + described_class.new.perform + + component = 'a' * 255 + + long_path = [ + 'uploads', + component, # project.full_path + component # filename + ].flatten.join('/') + + record = untracked_files_for_uploads.create!(path: long_path) + expect(record.reload.path.size).to eq(519) + end + it 'adds unhashed files to the untracked_files_for_uploads table' do described_class.new.perform @@ -235,10 +227,10 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq do # Very new or lightly-used installations that are running this migration # may not have an upload directory because they have no uploads. context 'when no files were ever uploaded' do - it 'does not add to the untracked_files_for_uploads table (and does not raise error)' do + it 'deletes the `untracked_files_for_uploads` table (and does not raise error)' do described_class.new.perform - expect(untracked_files_for_uploads.count).to eq(0) + expect(untracked_files_for_uploads.connection.table_exists?(:untracked_files_for_uploads)).to be_falsey end end end |