From 1ce61982edb7d6023faab2ca77873fd82a202c84 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sun, 16 Dec 2007 18:56:36 +0000 Subject: [PATCH] some bug fixing added some tests --- docs/upgrades/upgrade_7.4.18-7.5.0.pl | 1 + lib/WebGUI/Content/Asset.pm | 3 -- lib/WebGUI/Content/Maintenance.pm | 2 +- lib/WebGUI/Content/Upgrading.pm | 63 --------------------------- lib/WebGUI/URL/Content.pm | 5 ++- t/Content/Maintenance.t | 30 +++++++++++++ t/Content/Setup.t | 30 +++++++++++++ 7 files changed, 66 insertions(+), 68 deletions(-) delete mode 100644 lib/WebGUI/Content/Upgrading.pm create mode 100644 t/Content/Maintenance.t create mode 100644 t/Content/Setup.t diff --git a/docs/upgrades/upgrade_7.4.18-7.5.0.pl b/docs/upgrades/upgrade_7.4.18-7.5.0.pl index 18bbeca58..5bc10a811 100644 --- a/docs/upgrades/upgrade_7.4.18-7.5.0.pl +++ b/docs/upgrades/upgrade_7.4.18-7.5.0.pl @@ -58,6 +58,7 @@ sub addUrlAndContentHandlers { "WebGUI::Content::NotFound" ]); $config->delete("passthruUrls"); + unlink "../../lib/WebGUI/Setup.pm"; print "DONE!\n" unless $quiet; } diff --git a/lib/WebGUI/Content/Asset.pm b/lib/WebGUI/Content/Asset.pm index 7a55389e7..9caab81fe 100644 --- a/lib/WebGUI/Content/Asset.pm +++ b/lib/WebGUI/Content/Asset.pm @@ -181,9 +181,6 @@ sub page { $output = $asset->addMissing($assetUrl); } } - if ($output eq "chunked") { - $output = undef; - } return $output; } diff --git a/lib/WebGUI/Content/Maintenance.pm b/lib/WebGUI/Content/Maintenance.pm index ff6b720e8..ce87385b8 100644 --- a/lib/WebGUI/Content/Maintenance.pm +++ b/lib/WebGUI/Content/Maintenance.pm @@ -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 diff --git a/lib/WebGUI/Content/Upgrading.pm b/lib/WebGUI/Content/Upgrading.pm deleted file mode 100644 index 63a3f0264..000000000 --- a/lib/WebGUI/Content/Upgrading.pm +++ /dev/null @@ -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; - diff --git a/lib/WebGUI/URL/Content.pm b/lib/WebGUI/URL/Content.pm index 6035b9e63..6f4c88fb7 100644 --- a/lib/WebGUI/URL/Content.pm +++ b/lib/WebGUI/URL/Content.pm @@ -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); } diff --git a/t/Content/Maintenance.t b/t/Content/Maintenance.t new file mode 100644 index 000000000..484e5d0e7 --- /dev/null +++ b/t/Content/Maintenance.t @@ -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"); + diff --git a/t/Content/Setup.t b/t/Content/Setup.t new file mode 100644 index 000000000..357adddb8 --- /dev/null +++ b/t/Content/Setup.t @@ -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"); +