Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

don't delete profile if it's first one

  • Loading branch information...
commit ad27b8a258f4e282db97bc6f531a3b74a8551c74 1 parent 28e91c4
typester authored
View
11 lib/Catalyst/Plugin/FormValidator/Simple/Auto.pm
@@ -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
10 t/03_store_profile.t
@@ -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' );
Please sign in to comment.
Something went wrong with that request. Please try again.