From f8aa985a16635a9e99a257a89b619e86f22810ea Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 30 Apr 2022 15:21:10 -0500 Subject: [PATCH] Fix #4908: Prevent artist entries from being made on disambiguation tags. Don't allow artist entries to be created for deprecated tags. --- app/models/artist.rb | 4 ++++ test/unit/artist_test.rb | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/app/models/artist.rb b/app/models/artist.rb index adabc3295..e5d8a789c 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -174,6 +174,10 @@ class Artist < ApplicationRecord errors.add(:name, "'#{name}' is a #{tag.category_name.downcase} tag; artist entries can only be created for artist tags") end + if tag&.is_deprecated? + errors.add(:name, "'#{name}' is an ambiguous tag; try another name") + end + if tag_alias.present? errors.add(:name, "'#{name}' is aliased to '#{tag_alias.consequent_name}'") end diff --git a/test/unit/artist_test.rb b/test/unit/artist_test.rb index aeb7b14f0..316b4bc7b 100644 --- a/test/unit/artist_test.rb +++ b/test/unit/artist_test.rb @@ -549,6 +549,14 @@ class ArtistTest < ActiveSupport::TestCase assert_equal(true, artist.invalid?) assert_match(/'foo' is aliased to 'bar'/, artist.errors.full_messages.join) end + + should "not allow creating artist entries for deprecated tags" do + create(:tag, name: "orange", is_deprecated: true) + artist = build(:artist, name: "orange") + + assert_equal(true, artist.invalid?) + assert_match(/'orange' is an ambiguous tag/, artist.errors.full_messages.join) + end end context "when renaming" do