tests: fix broken tests.
This commit is contained in:
@@ -66,6 +66,10 @@ module Source
|
||||
elsif api_response[:file_url].present?
|
||||
api_response[:file_url][/\.(jpg|jpeg|png|gif)\z/i, 1]
|
||||
|
||||
# on yande.re, the file extension doesn't matter, any random string will work. This means we can't guess the true file extension.
|
||||
elsif domain == "yande.re"
|
||||
"png"
|
||||
|
||||
# the api_response wasn't available because it's a deleted post.
|
||||
elsif post_md5.present?
|
||||
%w[jpg png gif].find { |ext| http_exists?("https://#{domain}/image/#{post_md5}.#{ext}") }
|
||||
|
||||
@@ -246,6 +246,8 @@ class MediaAsset < ApplicationRecord
|
||||
# This can't be called inside a transaction because the transaction will
|
||||
# fail if there's a RecordNotUnique error when the asset already exists.
|
||||
def upload!(media_file, &block)
|
||||
media_file = MediaFile.open(media_file) unless media_file.is_a?(MediaFile)
|
||||
|
||||
raise Error, "File is corrupt" if media_file.is_corrupt?
|
||||
|
||||
media_asset = create!(file: media_file, status: :processing)
|
||||
|
||||
Reference in New Issue
Block a user