uploads: allow admins to upload videos more than 2 minutes long.

At some point the ability for admins to bypass the video length
restriction got lost.

ref: https://danbooru.donmai.us/forum_topics/14647
This commit is contained in:
evazion
2020-06-09 03:06:07 -05:00
parent d002701bc1
commit 8b5ffb4c43
2 changed files with 15 additions and 1 deletions

View File

@@ -53,7 +53,7 @@ class Upload < ApplicationRecord
end
def validate_video_duration(record)
if record.media_file.is_video? && record.media_file.duration > 120
if !record.uploader.is_admin? && record.media_file.is_video? && record.media_file.duration > 120
record.errors[:base] << "video must not be longer than 2 minutes"
end
end

View File

@@ -250,6 +250,20 @@ class UploadsControllerTest < ActionDispatch::IntegrationTest
end
end
context "for a 2+ minute long video" do
should "allow the upload if the user is an admin" do
@source = "https://twitter.com/7u_NABY/status/1269599527700295681"
post_auth uploads_path, create(:admin_user, created_at: 1.week.ago), params: { upload: { tag_string: "aaa", rating: "q", source: @source }}
assert_redirected_to Upload.last
assert_equal("mp4", Upload.last.file_ext)
assert_equal("completed", Upload.last.status)
assert_equal(1280, Upload.last.image_width)
assert_equal(720, Upload.last.image_height)
assert_equal("mp4", Upload.last.post.file_ext)
end
end
context "uploading a file from your computer" do
should "work for a jpeg file" do
upload = assert_uploaded("test/files/test.jpg", @user, tag_string: "aaa", rating: "e", source: "aaa")