Fix #4685: Tagging "aliased_tag -aliased_tag" adds aliased_tag.

This commit is contained in:
evazion
2021-02-03 23:24:12 -06:00
parent e28c28c03b
commit 50864c7147
2 changed files with 11 additions and 1 deletions

View File

@@ -472,8 +472,8 @@ class Post < ApplicationRecord
normalized_tags = apply_casesensitive_metatags(normalized_tags)
normalized_tags = normalized_tags.map(&:downcase)
normalized_tags = filter_metatags(normalized_tags)
normalized_tags = remove_negated_tags(normalized_tags)
normalized_tags = TagAlias.to_aliased(normalized_tags)
normalized_tags = remove_negated_tags(normalized_tags)
normalized_tags = %w(tagme) if normalized_tags.empty?
normalized_tags = add_automatic_tags(normalized_tags)
normalized_tags = remove_invalid_tags(normalized_tags)

View File

@@ -1214,6 +1214,16 @@ class PostTest < ActiveSupport::TestCase
assert_equal("aaa", @post.tag_string)
end
should "resolve aliases before removing negated tags" do
create(:tag_alias, antecedent_name: "female_focus", consequent_name: "female")
@post.update!(tag_string: "blah female_focus -female")
assert_equal("blah", @post.tag_string)
@post.update!(tag_string: "blah female_focus -female_focus")
assert_equal("blah", @post.tag_string)
end
should "resolve abbreviations" do
create(:tag, name: "hair_ribbon", post_count: 300_000)
create(:tag, name: "hakurei_reimu", post_count: 50_000)