FIX: `Upload#migrate_to_new_scheme` should not migrate system uploads.

This commit is contained in:
Guo Xiang Tan 2019-03-14 12:38:16 +08:00
parent 1bc96177dd
commit 40b03e717b
2 changed files with 13 additions and 1 deletions

View File

@ -224,7 +224,10 @@ class Upload < ActiveRecord::Base
max_file_size_kb = [SiteSetting.max_image_size_kb, SiteSetting.max_attachment_size_kb].max.kilobytes max_file_size_kb = [SiteSetting.max_image_size_kb, SiteSetting.max_attachment_size_kb].max.kilobytes
local_store = FileStore::LocalStore.new local_store = FileStore::LocalStore.new
scope = Upload.where("url NOT LIKE '%/original/_X/%'").order(id: :desc) scope = Upload.by_users
.where("url NOT LIKE '%/original/_X/%'")
.order(id: :desc)
scope = scope.limit(limit) if limit scope = scope.limit(limit) if limit
scope.each do |upload| scope.each do |upload|

View File

@ -250,4 +250,13 @@ describe Upload do
end end
end end
describe '.migrate_to_new_scheme' do
it 'should not migrate system uploads' do
SiteSetting.migrate_to_new_scheme = true
expect { Upload.migrate_to_new_scheme }
.to_not change { Upload.pluck(:url) }
end
end
end end