Fix #3952: Adding animated_gif tag to a ugoira post breaks the player.

This commit is contained in:
evazion
2018-10-10 23:48:45 -05:00
parent ca7e7e2877
commit e329764276
2 changed files with 26 additions and 0 deletions

View File

@@ -201,6 +201,14 @@ class Post < ApplicationRecord
file_ext =~ /jpg|jpeg|gif|png/i
end
def is_png?
file_ext =~ /png/i
end
def is_gif?
file_ext =~ /gif/i
end
def is_flash?
file_ext =~ /swf/i
end
@@ -765,6 +773,14 @@ class Post < ApplicationRecord
tags << "ugoira"
end
if !is_gif?
tags -= ["animated_gif"]
end
if !is_png?
tags -= ["animated_png"]
end
return tags
end

View File

@@ -1140,6 +1140,16 @@ class PostTest < ActiveSupport::TestCase
end
end
context "tagged with animated_gif or animated_png" do
should "remove the tag if not a gif or png" do
@post.update(tag_string: "tagme animated_gif")
assert_equal("tagme", @post.tag_string)
@post.update(tag_string: "tagme animated_png")
assert_equal("tagme", @post.tag_string)
end
end
should "have an array representation of its tags" do
post = FactoryBot.create(:post)
post.reload