uploads: refactor media asset validation logic.
Refactor the upload validation logic to not depend on the current user. Fixes several broken upload tests.
This commit is contained in:
@@ -105,6 +105,11 @@ class MediaFile
|
||||
dimensions.second
|
||||
end
|
||||
|
||||
# @return [Integer] the resolution of the file
|
||||
def resolution
|
||||
width * height
|
||||
end
|
||||
|
||||
# @return [String] the MD5 hash of the file, as a hex string.
|
||||
def md5
|
||||
Digest::MD5.file(file.path).hexdigest
|
||||
|
||||
@@ -18,6 +18,7 @@ class PostReplacementProcessor
|
||||
if media_file.md5 == post.md5
|
||||
media_asset = post.media_asset
|
||||
else
|
||||
MediaAsset.validate_media_file!(media_file, replacement.creator)
|
||||
media_asset = MediaAsset.upload!(media_file)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user