manually!
+
+=cut
+
+sub www_cleanup {
+ my ( $self ) = @_;
+
+ $self->cleanup;
+ $self->session->http->setRedirect( $self->session->url->page );
+ return "redirect";
+}
+
1;
diff --git a/lib/WebGUI/Wizard/HomePage.pm b/lib/WebGUI/Wizard/HomePage.pm
index f91554b6f..4cae3052c 100644
--- a/lib/WebGUI/Wizard/HomePage.pm
+++ b/lib/WebGUI/Wizard/HomePage.pm
@@ -20,7 +20,6 @@ sub _get_steps {
return [ qw(
pickStyle
chooseContent
- finalize
)
];
}
@@ -424,20 +423,5 @@ sub www_chooseContentSave {
return;
} ## end sub www_chooseContentSave
-#----------------------------------------------------------------------------
-
-=head2 www_finalize ( $output )
-
-Redirect the user to to the home page
-
-=cut
-
-sub www_finalize {
- my ($self) = @_;
- my $session = $self->session;
- $session->http->setCacheControl("none");
- $session->http->setRedirect( $session->url->gateway );
- return "redirect";
-}
1;
diff --git a/lib/WebGUI/Wizard/Setup.pm b/lib/WebGUI/Wizard/Setup.pm
index 30a930de2..317e8cb6d 100644
--- a/lib/WebGUI/Wizard/Setup.pm
+++ b/lib/WebGUI/Wizard/Setup.pm
@@ -22,7 +22,6 @@ sub _get_steps {
companyInformation
siteStats
defaultStyle
- finalize
)];
}
@@ -375,19 +374,20 @@ sub www_defaultStyleSave {
#----------------------------------------------------------------------------
-=head2 www_finalize ( )
+=head2 www_cleanup ( )
Give the user a choice to do the Home Page wizard
=cut
-sub www_finalize {
+sub www_cleanup {
my ( $self ) = @_;
my $session = $self->session;
my $form = $session->form;
$session->http->setCacheControl("none");
my $i18n = WebGUI::International->new( $session, "WebGUI" );
+ $self->cleanup;
# Delete specialState
$session->setting->remove( "specialState" );
@@ -399,34 +399,18 @@ sub www_finalize {
$starterForm->hidden( name => "styleTemplateId", value => $self->get('styleTemplateId') );
$starterForm->submit( value => $i18n->get( 'yes please' ) );
- my $finishForm = $self->getForm;
- $finishForm->hidden( name => "runStarter", value => 0 );
- $finishForm->submit( value => $i18n->get( 'no thanks' ) );
-
my $output = '' . $i18n->get('site starter title') . '
';
$output .= ' ' . $i18n->get('site starter body') . '
'
. '' . $starterForm->print . '
'
- . '' . $finishForm->print . '
'
+ . sprintf(
+ '',
+ $session->url->gateway,
+ $i18n->get('no thanks'),
+ )
. '
'
;
return $output;
}
-#----------------------------------------------------------------------------
-
-=head2 www_finalizeSave ( )
-
-User has declined to do the Home Page wizard
-
-=cut
-
-sub www_finalizeSave {
- my ( $self ) = @_;
- my $session = $self->session;
- my ( $form ) = $session->quick(qw( form ));
-
- $session->http->setRedirect( $session->url->gateway );
-}
-
1;
diff --git a/t/Wizard.t b/t/Wizard.t
index ad534a1bf..bd94a779b 100644
--- a/t/Wizard.t
+++ b/t/Wizard.t
@@ -29,7 +29,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
-plan tests => 29; # Increment this number for each test you create
+plan tests => 31; # Increment this number for each test you create
#----------------------------------------------------------------------------
# Basic API
@@ -127,6 +127,12 @@ cmp_deeply(
"thaw overwrites params"
);
+$wizard->cleanup;
+cmp_deeply(
+ $wizard->thaw,
+ { },
+ "cleanup clears scratch"
+);
#----------------------------------------------------------------------------
# dispatch
@@ -183,6 +189,15 @@ cmp_deeply(
'dispatch did not freeze error data'
);
+# Cleanup
+$wizard = WebGUI::Wizard::Test->new( $session ); # new object to clear currentStep
+$session->request->setup_body({
+ wizard_class => 'WebGUI::Wizard::Test',
+ wizard_step => 'five',
+});
+is( $wizard->dispatch, "cleanup", "cleanup sub run after last step saved" );
+
+
package WebGUI::Wizard::Test;
use base 'WebGUI::Wizard';
sub _get_steps { return [qw( one two three four five )] }
@@ -209,5 +224,12 @@ sub www_twoSave {
return "error";
}
+sub www_fiveSave {
+ return; # Success!
+}
+
+sub www_cleanup {
+ return "cleanup";
+}
#vim:ft=perl