posts: fix bug preventing *_(cosplay) tags from being added.

Bug: if `hatsune_miku` is an empty general tag, then tagging a post with
`hatsune_miku_(cosplay)` would fail because `hatsune_miku` wasn't a
character tag. This could cause tagging posts to fail when aliasing a
character tag back to an old name that was used in the past, but was now
an empty general tag.

Fix: only treat the *_(cosplay) tag as being in conflict with the base
tag when the base tag is nonempty.
This commit is contained in:
evazion
2020-08-27 22:39:16 -05:00
parent 346b143e40
commit b37fa87d4b
2 changed files with 9 additions and 1 deletions

View File

@@ -31,7 +31,7 @@ class TagNameValidator < ActiveModel::EachValidator
tag_name = TagAlias.to_aliased([$1]).first
tag = Tag.find_by_name(tag_name)
if tag.present? && !tag.character?
if tag.present? && !tag.empty? && !tag.character?
record.errors[attribute] << "#{tag_name} must be a character tag"
end
end