Skip to content

Commit

Permalink
failing test for new Text validation issue
Browse files Browse the repository at this point in the history
  • Loading branch information
karenetheridge committed Oct 20, 2016
1 parent 175ae39 commit 143f882
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions t/fields/text-subclass.t
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;

0 comments on commit 143f882

Please sign in to comment.