diff --git a/lib/MusicBrainz/Server/Form/Field/Comment.pm b/lib/MusicBrainz/Server/Form/Field/Comment.pm index 4632ac16391..721f00d415d 100644 --- a/lib/MusicBrainz/Server/Form/Field/Comment.pm +++ b/lib/MusicBrainz/Server/Form/Field/Comment.pm @@ -6,6 +6,9 @@ extends 'HTML::FormHandler::Field::Text'; has '+maxlength' => ( default => 255 ); has '+not_nullable' => ( default => 1 ); +has '+validate_when_empty' => ( + default => 1 +); apply ([ { diff --git a/t/lib/t/MusicBrainz/Server/Controller/Artist/Create.pm b/t/lib/t/MusicBrainz/Server/Controller/Artist/Create.pm index 0aeca3bebb5..5d49bd463d7 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/Artist/Create.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/Artist/Create.pm @@ -275,6 +275,41 @@ test 'MBS-10976: Private use characters U+E000..U+F8FF are allowed' => sub { ); }; +test 'MBS-12351: Space-only disambiguations are trimmed properly' => sub { + my $test = shift; + my $mech = $test->mech; + + prepare_test($test); + + $mech->get_ok('/artist/create'); + + my @edits = capture_edits { + $mech->submit_form_ok({ + with_fields => { + 'edit-artist.name' => 'Testy', + 'edit-artist.sort_name' => 'Testy', + 'edit-artist.comment' => ' ', + }, + }, + 'The form returned a 2xx response code') + } $test->c; + + ok( + $mech->uri =~ $artist_page_regexp, + 'The user is redirected to the artist page after entering the edit', + ); + + is(@edits, 1, 'The edit was entered'); + + my $edit = shift(@edits); + + is( + $edit->data->{comment}, + '', + 'The submitted comment is empty', + ); +}; + sub prepare_test { my $test = shift; diff --git a/t/lib/t/MusicBrainz/Server/Controller/Artist/EditRelationships.pm b/t/lib/t/MusicBrainz/Server/Controller/Artist/EditRelationships.pm index 477d6fadd79..62bc9e893ce 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/Artist/EditRelationships.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/Artist/EditRelationships.pm @@ -35,6 +35,7 @@ test 'Test adding a relationship' => sub { $mech->post('/artist/745c079d-374e-4436-9448-da92dedef3ce/edit', { 'edit-artist.name' => 'Test Artist', 'edit-artist.sort_name' => 'Artist, Test', + 'edit-artist.comment' => 'Yet Another Test Artist', 'edit-artist.type_id' => '1', 'edit-artist.gender_id' => '1', 'edit-artist.period.ended' => '1',