Apply aliases to characters in <character>_(cosplay) tags (#3409).
This commit is contained in:
@@ -21,7 +21,7 @@ class TagImplication < TagRelationship
|
|||||||
end
|
end
|
||||||
|
|
||||||
def automatic_tags_for(names)
|
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 << "cosplay" if tags.present?
|
||||||
tags.uniq
|
tags.uniq
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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_(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")
|
assert(Tag.where(name: "someone", category: 4).exists?, "expected 'someone' tag to be created")
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context "for a parent" do
|
context "for a parent" do
|
||||||
|
|||||||
Reference in New Issue
Block a user