-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
failing test for new Text validation issue
- Loading branch information
1 parent
175ae39
commit 143f882
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use strict; | ||
use warnings; | ||
use Test::More; | ||
|
||
{ | ||
package MyApp::Field::DuplicateText; | ||
use HTML::FormHandler::Moose; | ||
extends 'HTML::FormHandler::Field::Text'; | ||
|
||
apply [ { | ||
transform => sub { | ||
my $value = shift; | ||
# collapses down to a single entry if passed a list where all | ||
# values are identical | ||
return $value->[0] if | ||
defined $value | ||
and ref $value eq 'ARRAY' | ||
and map { $value->[0] eq $_ } @$value; | ||
return $value; | ||
}, | ||
}]; | ||
} | ||
|
||
|
||
# tests the TextCSV field | ||
{ | ||
package MyApp::Form::Test; | ||
use HTML::FormHandler::Moose; | ||
extends 'HTML::FormHandler'; | ||
|
||
has_field 'foo' => ( type => '+MyApp::Field::DuplicateText' ); | ||
has_field 'bar' => ( type => '+MyApp::Field::DuplicateText' ); | ||
} | ||
|
||
my $form = MyApp::Form::Test->new; | ||
ok( $form ); | ||
$form->process( params => { foo => '1', bar => ['2,2'] } ); | ||
|
||
TODO: { | ||
local $TODO = 'this test broke with commit 0cae37c6'; | ||
|
||
ok($form->validated, 'field of list values validates') | ||
or diag 'got errors: ', explain [ $form->errors_by_name ]; | ||
|
||
} | ||
|
||
done_testing; |