some bug fixing

added some tests
This commit is contained in:
JT Smith 2007-12-16 18:56:36 +00:00
parent b70ef9d23a
commit 1ce61982ed
7 changed files with 66 additions and 68 deletions

View file

@ -58,6 +58,7 @@ sub addUrlAndContentHandlers {
"WebGUI::Content::NotFound"
]);
$config->delete("passthruUrls");
unlink "../../lib/WebGUI/Setup.pm";
print "DONE!\n" unless $quiet;
}

View file

@ -181,9 +181,6 @@ sub page {
$output = $asset->addMissing($assetUrl);
}
}
if ($output eq "chunked") {
$output = undef;
}
return $output;
}

View file

@ -23,7 +23,7 @@ Package WebGUI::Content::Maintenance;
=head1 DESCRIPTION
A content handler that does whatever I tell it to do.
A content handler that displays a maintenance page while upgrading.
=head1 SYNOPSIS

View file

@ -1,63 +0,0 @@
package WebGUI::Content::Upgrading;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2007 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
=head1 NAME
Package WebGUI::Content::Upgrading
=head1 DESCRIPTION
A content handler that displays a maintenance page when in a special upgrade state.
=head1 SYNOPSIS
use WebGUI::Content::Upgrading;
my $output = WebGUI::Content::Upgrading::handler($session);
=head1 SUBROUTINES
These subroutines are available from this package:
=cut
#-------------------------------------------------------------------
=head2 handler ( session )
The content handler for this package.
=cut
sub handler {
my ($session) = @_;
if ($session->setting->get("specialState") eq "upgrading") {
my $output = "";
$session->http->sendHeader;
open(my $FILE,"<",$session->config->getWebguiRoot."/docs/maintenance.html");
while (<$FILE>) {
$session->output->print($_);
}
close($FILE);
return "none";
}
return;
}
1;

View file

@ -64,7 +64,10 @@ sub handler {
use strict;
if ($output) {
unless ($output eq "none" || $output eq "redirect") {
$session->output->print($output) unless ($output eq "chunked");
unless ($output eq "chunked") {
$session->http->sendHeader();
$session->output->print($output)
}
if ($session->errorHandler->canShowDebug()) {
$session->output->print($session->errorHandler->showDebug(),1);
}

30
t/Content/Maintenance.t Normal file
View file

@ -0,0 +1,30 @@
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2006 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use FindBin;
use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Content::Maintenance;
# load your modules here
use Test::More tests => 2; # increment this value for each test you create
my $session = WebGUI::Test->session;
# put your tests here
$session->setting->set("specialState", "upgrading");
isnt(WebGUI::Content::Maintenance::handler($session), undef, "Maintenance should return some output when in upgrade special state");
$session->setting->remove("specialState");
is(WebGUI::Content::Maintenance::handler($session), undef, "Maintenance shouldn't return anything when no special state is present");

30
t/Content/Setup.t Normal file
View file

@ -0,0 +1,30 @@
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2006 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use FindBin;
use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Content::Setup;
# load your modules here
use Test::More tests => 2; # increment this value for each test you create
my $session = WebGUI::Test->session;
# put your tests here
$session->setting->set("specialState", "init");
isnt(WebGUI::Content::Setup::handler($session), undef, "Setup should return some output when in init special state");
$session->setting->remove("specialState");
is(WebGUI::Content::Setup::handler($session), undef, "Setup shouldn't return anything when no special state is present");