[Replacements] Fix duration when replacing gif -> webm

This commit is contained in:
Earlopain 2022-05-22 21:39:21 +02:00
parent 2af251b387
commit b2a733d0c4
No known key found for this signature in database
GPG Key ID: 6CFB948E15246897
2 changed files with 13 additions and 1 deletions

View File

@ -82,6 +82,7 @@ class UploadService
post.image_width = upload.image_width
post.image_height = upload.image_height
post.file_size = upload.file_size
post.duration = upload.video_duration(upload.file.path)
post.source = "#{replacement.source}\n" + post.source
post.tag_string = upload.tag_string
# Reset ownership information on post.

View File

@ -146,7 +146,6 @@ class PostReplacementTest < ActiveSupport::TestCase
end
end
should "update post with new image" do
old_md5 = @post.md5
@replacement.approve! penalize_current_uploader: true
@ -249,6 +248,18 @@ class PostReplacementTest < ActiveSupport::TestCase
@replacement.approve! penalize_current_uploader: false
assert_equal ["Status must be pending or original to approve"], @replacement.errors.full_messages
end
context "update the duration" do
setup do
@replacement = FactoryBot.create(:webm_replacement, creator: @user, creator_ip_addr: '127.0.0.1', post: @post)
end
should "when the replacement is a video" do
@replacement.approve! penalize_current_uploader: false
@post.reload
assert @post.duration
end
end
end
context "Toggle:" do