diff --git a/app/logical/tag_name_validator.rb b/app/logical/tag_name_validator.rb index 85c714fde..b4886f33d 100644 --- a/app/logical/tag_name_validator.rb +++ b/app/logical/tag_name_validator.rb @@ -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 diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index c45d83bc3..ef5c02c21 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -1296,6 +1296,14 @@ class PostTest < ActiveSupport::TestCase refute(@post.has_tag?("cosplay")) assert(@post.warnings[:base].grep(/Couldn't add tag/).present?) end + + should "allow creating a _(cosplay) tag for an empty general tag" do + @tag = create(:tag, name: "hatsune_miku", post_count: 0, category: Tag.categories.general) + @post = create(:post, tag_string: "hatsune_miku_(cosplay)") + + assert_equal("cosplay hatsune_miku hatsune_miku_(cosplay)", @post.reload.tag_string) + assert_equal(true, @tag.reload.character?) + end end context "that has been updated" do