Permalink
Browse files

don't delete profile if it's first one

  • Loading branch information...
1 parent 28e91c4 commit ad27b8a258f4e282db97bc6f531a3b74a8551c74 typester committed Apr 7, 2007
Showing with 15 additions and 6 deletions.
  1. +7 −4 lib/Catalyst/Plugin/FormValidator/Simple/Auto.pm
  2. +8 −2 t/03_store_profile.t
@@ -199,11 +199,14 @@ sub forward {
my $res;
if ( my $profile = $c->config->{validator}{profiles}{ $action } ) {
# We only need to create a new validator if there is a new profile
- local $c->{validator} = FormValidator::Simple->new;
- local $c->{validator_profile} = $action;
+ {
+ local $c->{validator} = FormValidator::Simple->new;
+ local $c->{validator_profile} = $action;
- $c->form(%$profile);
- $res = $c->NEXT::forward(@_);
+ $c->form(%$profile);
+ $res = $c->NEXT::forward(@_);
+ }
+ $c->{validator_profile} ||= $action; # don't delete profile if it's first one
}
else {
$res = $c->NEXT::forward(@_);
View
@@ -36,10 +36,16 @@ use warnings;
$c->forward('action1');
}
}
+
+ sub action3 : Global {
+ my ( $self, $c ) = @_;
+ $c->forward('action1');
+ $c->res->body( $c->validator_profile );
+ }
}
use Catalyst::Test 'TestApp';
-use Test::More tests => 4;
+use Test::More tests => 5;
use HTTP::Request::Common;
@@ -49,4 +55,4 @@ is( $res->content, 'action1', 'store profile ok (action based)');
ok( $res = request(POST '/action2'), 'request ok' );
is( $res->content, 'action1', 'store profile ok (forward based)');
-
+is( get('/action3'), 'action1', 'first profile is also stored after forwarding' );

0 comments on commit ad27b8a

Please sign in to comment.