Fix #4683: Automove _(style) tags when artists are processed via BUR.

This commit is contained in:
evazion
2021-02-03 21:27:35 -06:00
parent 19974d3ab1
commit b03d8e728d
2 changed files with 23 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ class TagMover
move_aliases!
move_implications!
move_cosplay_tag!
move_style_tag!
move_artist!
move_wiki!
move_saved_searches!
@@ -84,6 +85,15 @@ class TagMover
end
end
def move_style_tag!
old_style_tag = "#{old_tag.name}_(style)"
new_style_tag = "#{new_tag.name}_(style)"
if old_tag.artist? && Tag.nonempty.exists?(name: old_style_tag)
TagMover.new(old_style_tag, new_style_tag).move!
end
end
def move_saved_searches!
SavedSearch.rewrite_queries!(old_tag.name, new_tag.name)
end

View File

@@ -297,6 +297,19 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
assert_equal("tohsaka_rin_(cosplay)", @wiki.reload.title)
end
end
context "when renaming an artist tag with a *_(style) tag" do
should "move the *_(style) tag as well" do
create(:tag, name: "tanaka_takayuki", category: Tag.categories.artist)
@post = create(:post, tag_string: "tanaka_takayuki_(style)")
@wiki = create(:wiki_page, title: "tanaka_takayuki_(style)")
create_bur!("rename tanaka_takayuki -> tony_taka", @admin)
assert_equal("tony_taka_(style)", @post.reload.tag_string)
assert_equal("tony_taka_(style)", @wiki.reload.title)
end
end
end
context "the nuke command" do