Fix #3952: Adding animated_gif tag to a ugoira post breaks the player.
This commit is contained in:
@@ -201,6 +201,14 @@ class Post < ApplicationRecord
|
|||||||
file_ext =~ /jpg|jpeg|gif|png/i
|
file_ext =~ /jpg|jpeg|gif|png/i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_png?
|
||||||
|
file_ext =~ /png/i
|
||||||
|
end
|
||||||
|
|
||||||
|
def is_gif?
|
||||||
|
file_ext =~ /gif/i
|
||||||
|
end
|
||||||
|
|
||||||
def is_flash?
|
def is_flash?
|
||||||
file_ext =~ /swf/i
|
file_ext =~ /swf/i
|
||||||
end
|
end
|
||||||
@@ -765,6 +773,14 @@ class Post < ApplicationRecord
|
|||||||
tags << "ugoira"
|
tags << "ugoira"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if !is_gif?
|
||||||
|
tags -= ["animated_gif"]
|
||||||
|
end
|
||||||
|
|
||||||
|
if !is_png?
|
||||||
|
tags -= ["animated_png"]
|
||||||
|
end
|
||||||
|
|
||||||
return tags
|
return tags
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1140,6 +1140,16 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
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
|
should "have an array representation of its tags" do
|
||||||
post = FactoryBot.create(:post)
|
post = FactoryBot.create(:post)
|
||||||
post.reload
|
post.reload
|
||||||
|
|||||||
Reference in New Issue
Block a user