diff --git a/app/models/artist.rb b/app/models/artist.rb index 0ed4c96e3..c5379f531 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -242,7 +242,8 @@ class Artist < ApplicationRecord end def normalize_other_names - self.other_names = other_names.map { |x| Artist.normalize_name(x) } + self.other_names = other_names.map { |x| Artist.normalize_name(x) }.uniq + self.other_names -= [name] end end diff --git a/test/unit/artist_test.rb b/test/unit/artist_test.rb index 76117910d..600cb42b2 100644 --- a/test/unit/artist_test.rb +++ b/test/unit/artist_test.rb @@ -407,7 +407,7 @@ class ArtistTest < ActiveSupport::TestCase end should "normalize its other names" do - artist = FactoryBot.create(:artist, :name => "a1", :other_names => "aaa bbb ccc_ddd") + artist = FactoryBot.create(:artist, name: "a1", other_names: "a1 aaa aaa AAA bbb ccc_ddd") assert_equal("aaa bbb ccc_ddd", artist.other_names_string) end