Apply aliases to characters in <character>_(cosplay) tags (#3409).

This commit is contained in:
evazion
2017-12-06 12:33:06 -06:00
parent 131c0109d4
commit d6d73404a9
2 changed files with 9 additions and 1 deletions

View File

@@ -21,7 +21,7 @@ class TagImplication < TagRelationship
end
def automatic_tags_for(names)
tags = names.grep(/\A(.+)_\(cosplay\)\Z/) { "char:#{$1}" }
tags = names.grep(/\A(.+)_\(cosplay\)\Z/) { "char:#{TagAlias.to_aliased([$1]).first}" }
tags << "cosplay" if tags.present?
tags.uniq
end

View File

@@ -790,6 +790,14 @@ class PostTest < ActiveSupport::TestCase
assert(Tag.where(name: "someone_(cosplay)", category: 4).exists?, "expected 'someone_(cosplay)' tag to be created as character")
assert(Tag.where(name: "someone", category: 4).exists?, "expected 'someone' tag to be created")
end
should "apply aliases when the character tag is added" do
FactoryGirl.create(:tag_alias, antecedent_name: "jim", consequent_name: "james")
@post.add_tag("jim_(cosplay)")
@post.save
assert(@post.has_tag?("james"), "expected 'jim' to be aliased to 'james'")
end
end
context "for a parent" do