Remove hack to allow IO files in Active Storage
We were using this hack in order to allow `File.new` attachments in tests files. However, we can use the `fixture_file_upload` helper instead. Just like it happened with `file_fixture`, this helper method doesn't work in fixtures, so in this case we're using `Rack::Test::UploadedFile` instead.
This commit is contained in:
@@ -6,9 +6,7 @@ module HasAttachment
|
||||
has_one_attached attribute
|
||||
|
||||
define_method :"#{attribute}=" do |file|
|
||||
if file.is_a?(IO)
|
||||
send(attribute).attach(io: file, filename: File.basename(file.path))
|
||||
elsif file.nil?
|
||||
if file.nil?
|
||||
send(attribute).detach
|
||||
else
|
||||
send(attribute).attach(file)
|
||||
|
||||
Reference in New Issue
Block a user