FEATURE: add support for "skip_validations" option in UploadCreator (#13094)

FIX: do not validate uploads when running `uploads:fix_missing_s3` task
This commit is contained in:
Arpit Jalan
2021-05-19 20:54:52 +05:30
committed by GitHub
parent 075cd07a07
commit 130160537c
3 changed files with 31 additions and 3 deletions

View File

@@ -504,6 +504,32 @@ RSpec.describe UploadCreator do
expect(FastImage.size(Discourse.store.path_for(upload))).to eq([320, 320])
end
end
describe 'skip validations' do
let(:filename) { "small.pdf" }
let(:file) { file_from_fixtures(filename, "pdf") }
before do
SiteSetting.authorized_extensions = 'png|jpg'
end
it 'creates upload when skip_validations is true' do
upload = UploadCreator.new(file, filename,
skip_validations: true
).create_for(user.id)
expect(upload.persisted?).to eq(true)
expect(upload.original_filename).to eq(filename)
end
it 'does not create upload when skip_validations is false' do
upload = UploadCreator.new(file, filename,
skip_validations: false
).create_for(user.id)
expect(upload.persisted?).to eq(false)
end
end
end
describe '#clean_svg!' do