artists: normalize group names.

Normalize artist group names following the same rules as artist other names.

This means artist group names now use underscores instead of spaces.
It also means extra space characters at the beginning and end of names
is stripped, and Unicode characters are normalized.

Fixes #4647, which was caused by users accidentally replacing group
names with a single space character when trying to remove a group.
This commit is contained in:
evazion
2022-01-20 00:09:52 -06:00
parent 0376765847
commit 02c9498860
3 changed files with 34 additions and 0 deletions

View File

@@ -412,6 +412,22 @@ class ArtistTest < ActiveSupport::TestCase
should normalize_attribute(:other_names).from("_foo_ Bar").to(["_foo_", "Bar"])
end
context "group name" do
should normalize_attribute(:group_name).from(" ").to("")
should normalize_attribute(:group_name).from(" foo").to("foo")
should normalize_attribute(:group_name).from("foo ").to("foo")
should normalize_attribute(:group_name).from("___foo").to("___foo")
should normalize_attribute(:group_name).from("foo___").to("foo___")
should normalize_attribute(:group_name).from("foo\n").to("foo")
should normalize_attribute(:group_name).from("foo bar").to("foo_bar")
should normalize_attribute(:group_name).from("foo bar").to("foo_bar")
should normalize_attribute(:group_name).from("foo___bar").to("foo___bar")
should normalize_attribute(:group_name).from(" _Foo Bar_ ").to("_Foo_Bar_")
should normalize_attribute(:group_name).from("_foo_ Bar").to("_foo__Bar")
should normalize_attribute(:group_name).from("pokémon".unicode_normalize(:nfd)).to("pokémon".unicode_normalize(:nfkc))
should normalize_attribute(:group_name).from("🏳️‍🌈").to("🏳️‍🌈")
end
should "search on its name should return results" do
artist = FactoryBot.create(:artist, :name => "artist")