fixes #2307
This commit is contained in:
@@ -48,4 +48,8 @@ class PixivUgoiraService
|
||||
@content_type = data[:ugoira_content_type]
|
||||
end
|
||||
end
|
||||
|
||||
def empty?
|
||||
@frame_data.nil?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -53,6 +53,10 @@ class Upload < ActiveRecord::Base
|
||||
unless is_valid_content_type?
|
||||
raise "invalid content type (only JPEG, PNG, GIF, SWF, and WebM files are allowed)"
|
||||
end
|
||||
|
||||
if is_ugoira? && ugoira_service.empty?
|
||||
raise "missing frame data for ugoira"
|
||||
end
|
||||
end
|
||||
|
||||
def validate_md5_confirmation
|
||||
|
||||
BIN
test/files/invalid_ugoira.zip
Normal file
BIN
test/files/invalid_ugoira.zip
Normal file
Binary file not shown.
@@ -32,6 +32,10 @@ module UploadTestMethods
|
||||
def upload_jpeg(path)
|
||||
upload_file(path, "image/jpeg", File.basename(path))
|
||||
end
|
||||
|
||||
def upload_zip(path)
|
||||
upload_file(path, "application/zip", File.basename(path))
|
||||
end
|
||||
end
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
|
||||
@@ -101,6 +101,15 @@ class UploadTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
context "downloader" do
|
||||
context "for a zip that is not an ugoira" do
|
||||
should "not validate" do
|
||||
FileUtils.cp("#{Rails.root}/test/files/invalid_ugoira.zip", "#{Rails.root}/tmp")
|
||||
@upload = Upload.create(:file => upload_zip("#{Rails.root}/tmp/invalid_ugoira.zip"), :rating => "q", :tag_string => "xxx")
|
||||
@upload.process!
|
||||
assert_equal("error: RuntimeError - missing frame data for ugoira", @upload.status)
|
||||
end
|
||||
end
|
||||
|
||||
context "that is an ugoira" do
|
||||
setup do
|
||||
@url = "http://www.pixiv.net/member_illust.php?mode=medium&illust_id=46378654"
|
||||
|
||||
Reference in New Issue
Block a user