diff options
author | Michael Kozono <mkozono@gmail.com> | 2017-11-24 00:49:04 -0800 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2017-12-01 15:26:42 -0800 |
commit | 473ddfb453d820f1a32fb48477e17ba45bdbd2f0 (patch) | |
tree | aa64312ad413539aec7e0091e143b25628a313c0 /spec | |
parent | 61a73cadb7f21de9f863fc1a16f13880861ac9f4 (diff) | |
download | gitlab-ce-473ddfb453d820f1a32fb48477e17ba45bdbd2f0.tar.gz |
Don’t recreate deleted uploads
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb | 14 | ||||
-rw-r--r-- | spec/migrations/track_untracked_uploads_spec.rb | 9 |
2 files changed, 16 insertions, 7 deletions
diff --git a/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb b/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb index 623725bffca..85da8ac5b1e 100644 --- a/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb +++ b/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb @@ -392,37 +392,37 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads::UntrackedFile do context 'for an appearance logo file path' do it 'returns the ID as a string' do - assert_model_id('/-/system/appearance/logo/1/some_logo.jpg', '1') + assert_model_id('/-/system/appearance/logo/1/some_logo.jpg', 1) end end context 'for an appearance header_logo file path' do it 'returns the ID as a string' do - assert_model_id('/-/system/appearance/header_logo/1/some_logo.jpg', '1') + assert_model_id('/-/system/appearance/header_logo/1/some_logo.jpg', 1) end end context 'for a pre-Markdown Note attachment file path' do it 'returns the ID as a string' do - assert_model_id('/-/system/note/attachment/1234/some_attachment.pdf', '1234') + assert_model_id('/-/system/note/attachment/1234/some_attachment.pdf', 1234) end end context 'for a user avatar file path' do it 'returns the ID as a string' do - assert_model_id('/-/system/user/avatar/1234/avatar.jpg', '1234') + assert_model_id('/-/system/user/avatar/1234/avatar.jpg', 1234) end end context 'for a group avatar file path' do it 'returns the ID as a string' do - assert_model_id('/-/system/group/avatar/1234/avatar.jpg', '1234') + assert_model_id('/-/system/group/avatar/1234/avatar.jpg', 1234) end end context 'for a project avatar file path' do it 'returns the ID as a string' do - assert_model_id('/-/system/project/avatar/1234/avatar.jpg', '1234') + assert_model_id('/-/system/project/avatar/1234/avatar.jpg', 1234) end end @@ -430,7 +430,7 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads::UntrackedFile do it 'returns the ID as a string' do project = create(:project) - assert_model_id("/#{project.full_path}/#{SecureRandom.hex}/Some file.jpg", project.id.to_s) + assert_model_id("/#{project.full_path}/#{SecureRandom.hex}/Some file.jpg", project.id) end end end diff --git a/spec/migrations/track_untracked_uploads_spec.rb b/spec/migrations/track_untracked_uploads_spec.rb index 01bfe26744f..9fa586ff177 100644 --- a/spec/migrations/track_untracked_uploads_spec.rb +++ b/spec/migrations/track_untracked_uploads_spec.rb @@ -75,6 +75,15 @@ describe TrackUntrackedUploads, :migration, :sidekiq do expect(project1.uploads.where(uploader: 'FileUploader').first.attributes).to include(@project1_markdown_attributes) end + it 'ignores uploads for deleted models' do + user2.destroy + project2.destroy + + expect do + migrate! + end.to change { uploads.count }.from(4).to(5) + end + it 'the temporary table untracked_files_for_uploads no longer exists' do migrate! |