artists: filter out duplicates from other names (#4028).

This commit is contained in:
evazion 2018-12-27 15:03:11 -06:00
parent 0dd44e64a4
commit 286bf2f285
2 changed files with 3 additions and 2 deletions

View File

@ -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

View File

@ -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