[Catalyst-commits] r12888 - in Catalyst-Plugin-FormValidator/trunk:
lib/Catalyst/Plugin t t/lib
dhoss at dev.catalyst.perl.org
dhoss at dev.catalyst.perl.org
Mon Feb 15 23:55:25 GMT 2010
Author: dhoss
Date: 2010-02-15 23:55:23 +0000 (Mon, 15 Feb 2010)
New Revision: 12888
Modified:
Catalyst-Plugin-FormValidator/trunk/lib/Catalyst/Plugin/FormValidator.pm
Catalyst-Plugin-FormValidator/trunk/t/04basic.t
Catalyst-Plugin-FormValidator/trunk/t/lib/TestApp.pm
Log:
successful conversion to Moose - with tests\!
Modified: Catalyst-Plugin-FormValidator/trunk/lib/Catalyst/Plugin/FormValidator.pm
===================================================================
--- Catalyst-Plugin-FormValidator/trunk/lib/Catalyst/Plugin/FormValidator.pm 2010-02-15 23:45:45 UTC (rev 12887)
+++ Catalyst-Plugin-FormValidator/trunk/lib/Catalyst/Plugin/FormValidator.pm 2010-02-15 23:55:23 UTC (rev 12888)
@@ -2,20 +2,18 @@
use Moose::Role;
use Data::FormValidator;
-
our $VERSION = '0.05';
$VERSION = eval $VERSION;
-has 'form' => (
- is => 'rw',
- required => 1,
- lazy_build => 1,
-);
-
-sub _build_form {
- my $self = shift;
- my $c = $self->context_class;
- return Data::FormValidator->check( $c->request->parameters, {} );
+sub form {
+ my ($c, @opts) = @_;
+ if ( @opts ) {
+ my $form = Data::FormValidator->check( $c->request->parameters, {@opts});
+ return $form;
+ }
+ else {
+ return Data::FormValidator->check( $c->request->parameters, {} );
+ }
}
=head1 NAME
@@ -60,7 +58,6 @@
=cut
-
=head1 SEE ALSO
L<Catalyst>, L<Data::FormValidator>
Modified: Catalyst-Plugin-FormValidator/trunk/t/04basic.t
===================================================================
--- Catalyst-Plugin-FormValidator/trunk/t/04basic.t 2010-02-15 23:45:45 UTC (rev 12887)
+++ Catalyst-Plugin-FormValidator/trunk/t/04basic.t 2010-02-15 23:55:23 UTC (rev 12888)
@@ -6,10 +6,26 @@
use FindBin;
use lib "$FindBin::Bin/lib";
use HTTP::Request::Common;
+use Data::Dumper;
BEGIN { use_ok 'Catalyst::Test','TestApp' }
my $response = request GET "/form_test";
ok( $response->is_success, "got initial url");
+my $response2 = request POST '/form_test',
+Content_Type => 'form-data',
+Content => [
+ testinput => "test"
+];
+like($response->content, qr/testinput/, "successful post is proper");
+
+my $response3 = request POST '/form_test',
+Content_Type => 'form-data',
+Content => [
+ testinput => "test"
+];
+
+like($response->content, qr//, "unsuccessful post is proper");
+
done_testing;
\ No newline at end of file
Modified: Catalyst-Plugin-FormValidator/trunk/t/lib/TestApp.pm
===================================================================
--- Catalyst-Plugin-FormValidator/trunk/t/lib/TestApp.pm 2010-02-15 23:45:45 UTC (rev 12887)
+++ Catalyst-Plugin-FormValidator/trunk/t/lib/TestApp.pm 2010-02-15 23:55:23 UTC (rev 12888)
@@ -5,8 +5,9 @@
use Catalyst::Runtime 5.80;
use Catalyst qw/
+ -Debug
FormValidator
/;
extends 'Catalyst';
TestApp->setup;
-__PACKAGE__->meta->make_immutable;
\ No newline at end of file
+__PACKAGE__->meta->make_immutable;
More information about the Catalyst-commits
mailing list