diff --git a/app/models/upload.rb b/app/models/upload.rb index 6883d9ec3..e7b2651fb 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -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 diff --git a/test/functional/uploads_controller_test.rb b/test/functional/uploads_controller_test.rb index d9a663584..e0c2617f3 100644 --- a/test/functional/uploads_controller_test.rb +++ b/test/functional/uploads_controller_test.rb @@ -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")