BURs: move the is_banned flag when aliasing artists.

When a banned artist tag is aliased into a nonbanned artist tag, move
the is_banned flag from the old artist entry to the new artist_entry.

Related to #4940. Fixes a case where a banned artist could lose the
banned status when it was moved.
This commit is contained in:
evazion
2022-01-11 11:16:48 -06:00
parent 40d6351249
commit f8768fd6b7
2 changed files with 13 additions and 0 deletions

View File

@@ -156,12 +156,14 @@ class TagMover
new_artist.group_name = old_artist.group_name unless new_artist.group_name.present?
new_artist.url_string += "\n" + old_artist.url_string
new_artist.is_deleted = false
new_artist.is_banned = old_artist.is_banned || new_artist.is_banned
new_artist.save!
old_artist.other_names = [new_artist.name]
old_artist.group_name = ""
old_artist.url_string = ""
old_artist.is_deleted = true
old_artist.is_banned = false
old_artist.save!
end

View File

@@ -248,6 +248,17 @@ class TagAliasTest < ActiveSupport::TestCase
assert_equal(%w[-https://twitter.com/222 -https://twitter.com/333 https://twitter.com/111 https://twitter.com/444], @artist2.url_array)
end
should "move the is_banned flag from the old artist entry to the new artist entry" do
@old_artist = create(:artist, name: "old_artist", is_banned: true)
@new_artist = create(:artist, name: "new_artist", is_banned: false)
TagAlias.approve!(antecedent_name: "old_artist", consequent_name: "new_artist", approver: @admin)
perform_enqueued_jobs
assert_equal(true, @new_artist.reload.is_banned)
assert_equal(false, @old_artist.reload.is_banned)
end
should "ignore the old artist if it has been deleted" do
@artist1 = create(:artist, name: "aaa", group_name: "g_aaa", other_names: "111 222", url_string: "https://twitter.com/111\n-https://twitter.com/222", is_deleted: true)
@artist2 = create(:artist, name: "bbb", other_names: "111 333", url_string: "https://twitter.com/111\n-https://twitter.com/333\nhttps://twitter.com/444")