2021-02-11 10:09:11 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class RenameableUpload < SimpleDelegator
|
|
|
|
attr_accessor :original_filename
|
|
|
|
|
|
|
|
# Get a fixture file with a new unique name, and the same extension
|
|
|
|
def self.unique_file(name)
|
2021-04-22 17:09:53 -04:00
|
|
|
upload = new(Rack::Test::UploadedFile.new("spec/fixtures/#{name}"))
|
2021-02-11 10:09:11 -05:00
|
|
|
ext = File.extname(name)
|
|
|
|
new_name = File.basename(FactoryBot.generate(:filename), '.*')
|
|
|
|
upload.original_filename = new_name + ext
|
|
|
|
|
|
|
|
upload
|
|
|
|
end
|
|
|
|
end
|