posts: don't remove sound tag from Flash posts.
Fix a bug in 28237e2e0 where editing a Flash post would automatically remove the `sound` tag.
This commit is contained in:
@@ -402,7 +402,7 @@ class Post < ApplicationRecord
|
||||
end
|
||||
|
||||
def add_automatic_tags(tags)
|
||||
tags -= %w[incredibly_absurdres absurdres highres lowres flash video ugoira animated_gif animated_png exif_rotation non-repeating_animation non-web_source wide_image tall_image sound]
|
||||
tags -= %w[incredibly_absurdres absurdres highres lowres flash video ugoira animated_gif animated_png exif_rotation non-repeating_animation non-web_source wide_image tall_image]
|
||||
|
||||
if tags.size >= 30
|
||||
tags -= ["tagme"]
|
||||
@@ -472,6 +472,9 @@ class Post < ApplicationRecord
|
||||
tags << "exif_rotation" if media_asset.is_rotated?
|
||||
tags << "non-repeating_animation" if media_asset.is_non_repeating_animation?
|
||||
tags << "ai-generated" if media_asset.is_ai_generated?
|
||||
|
||||
# Allow Flash files to be manually tagged as `sound`; other files are automatically tagged.
|
||||
tags -= ["sound"] unless is_flash?
|
||||
tags << "sound" if media_asset.has_sound?
|
||||
|
||||
tags
|
||||
|
||||
@@ -1269,7 +1269,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
@media_asset = MediaAsset.upload!("test/files/mp4/test-silent-audio.mp4")
|
||||
@post.update!(md5: @media_asset.md5)
|
||||
@post.reload.update!(tag_string: "sound")
|
||||
assert_equal("animated tagme", @post.tag_string)
|
||||
assert_equal("animated", @post.tag_string)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1282,6 +1282,15 @@ class PostTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "a Flash file with the sound tag" do
|
||||
should "not automatically remove the sound tag" do
|
||||
@post = create(:post, file_ext: "swf", media_asset: build(:media_asset, file_ext: "swf"))
|
||||
@post.update!(tag_string: "sound")
|
||||
|
||||
assert_equal("flash sound", @post.tag_string)
|
||||
end
|
||||
end
|
||||
|
||||
context "a post with a non-web source" do
|
||||
should "automatically add the non-web_source tag" do
|
||||
@post.update!(source: "this was once revealed to me in a dream")
|
||||
|
||||
Reference in New Issue
Block a user