From e28c28c03bcfb7cf416e94e1d5e1260a9b2bb795 Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 3 Feb 2021 23:17:13 -0600 Subject: [PATCH] BURs: when moving artists, add old tag to other names. When aliasing or renaming an artist, add their old tag name to their other names. --- app/logical/tag_mover.rb | 4 +++- test/unit/bulk_update_request_test.rb | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/logical/tag_mover.rb b/app/logical/tag_mover.rb index b7cd41f42..7398aacc2 100644 --- a/app/logical/tag_mover.rb +++ b/app/logical/tag_mover.rb @@ -35,7 +35,9 @@ class TagMover return unless old_tag.artist? && old_artist.present? && !old_artist.is_deleted? if new_artist.nil? - old_artist.update!(name: new_tag.name) + old_artist.name = new_tag.name + old_artist.other_names += [old_tag.name] + old_artist.save! else merge_artists! end diff --git a/test/unit/bulk_update_request_test.rb b/test/unit/bulk_update_request_test.rb index 6a7e8664d..8990f36d2 100644 --- a/test/unit/bulk_update_request_test.rb +++ b/test/unit/bulk_update_request_test.rb @@ -285,6 +285,12 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase assert_equal(["Can't rename aaa -> bbb ('aaa' has more than 200 posts, use an alias instead)"], @bur.errors.full_messages) end + context "when moving an artist" do + should "add the artist's old tag name to their other names" do + assert_equal(["foo"], @artist.reload.other_names) + end + end + context "when renaming a character tag with a *_(cosplay) tag" do should "move the *_(cosplay) tag as well" do @post = create(:post, tag_string: "toosaka_rin_(cosplay)")