From 75b39feb084f22a7c4dc2c4ea77204d868286e0c Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 8 Oct 2008 16:52:52 +0000 Subject: [PATCH] final fixes for AssetExportHtml test --- lib/WebGUI/AssetExportHtml.pm | 2 +- lib/WebGUI/i18n/English/Asset.pm | 4 ++-- t/Asset/AssetExportHtml.t | 41 +++++++++++++++++++------------- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/lib/WebGUI/AssetExportHtml.pm b/lib/WebGUI/AssetExportHtml.pm index 1a98375b3..f7de3c32d 100644 --- a/lib/WebGUI/AssetExportHtml.pm +++ b/lib/WebGUI/AssetExportHtml.pm @@ -239,7 +239,7 @@ sub exportAsHtml { # and it must be a number. if( !looks_like_number($depth) ) { $returnCode = 0; - $message = sprintf $i18n->get('%d is not a valid depth'), $depth; + $message = sprintf $i18n->get('%s is not a valid depth'), $depth; return ($returnCode, $message); } diff --git a/lib/WebGUI/i18n/English/Asset.pm b/lib/WebGUI/i18n/English/Asset.pm index 17b60cedb..d6e120720 100644 --- a/lib/WebGUI/i18n/English/Asset.pm +++ b/lib/WebGUI/i18n/English/Asset.pm @@ -1145,8 +1145,8 @@ Couldn't open %-s because %-s
context => q{Error message in exportAsHtml for an illegal parameter.}, }, - '%d is not a valid depth' => { - message => q{%d is not a valid depth}, + '%s is not a valid depth' => { + message => q{%s is not a valid depth}, lastUpdated => 0, context => q{Error message in exportAsHtml for an illegal parameter.}, }, diff --git a/t/Asset/AssetExportHtml.t b/t/Asset/AssetExportHtml.t index 3418ede6a..c259387f3 100644 --- a/t/Asset/AssetExportHtml.t +++ b/t/Asset/AssetExportHtml.t @@ -370,16 +370,20 @@ chmod 0000, $guidPath->stringify; $config->set('exportPath', $unwritablePath->absolute->stringify); $session->http->setNoHeader(1); -eval { $home->exportWriteFile() }; -$e = Exception::Class->caught(); -isa_ok($e, 'WebGUI::Error', "exportWriteFile throws if it can't create the export path"); -cmp_deeply( - $e, - methods( - error => "can't create exportPath $unwritablePath", - ), - "exportWriteFile throws if it can't create the export path" -); +SKIP: { + skip 'Root will cause this test to fail since it does not obey file permissions', 2 + if $< == 0; + eval { $home->exportWriteFile() }; + $e = Exception::Class->caught(); + isa_ok($e, 'WebGUI::Error', "exportWriteFile throws if it can't create the export path"); + cmp_deeply( + $e, + methods( + error => "can't create exportPath $unwritablePath", + ), + "exportWriteFile throws if it can't create the export path" + ); +} # the exception was thrown, but make sure that the file also wasn't written # can't call exportGetUrlAsPath on $home right now, since the path is @@ -940,14 +944,19 @@ is($@, '', "exportAsHtml catches exportPath is file exception"); is($success, 0, "exportAsHtml returns 0 if exportPath is a file"); is($message, "$exportPathFile isn't a directory", "exportAsHtml returns correct message if exportPath is a file"); -# can't create export path -chmod 0000, $tempDirectory; $config->set('exportPath', $inaccessibleDirectory->stringify); +SKIP: { + skip 'Root will cause this test to fail since it does not obey file permissions', 3 + if $< == 0; -eval { ($success, $message) = $home->exportAsHtml( { userId => 3, depth => 99 } ) }; -is($@, '', "exportAsHtml catches uncreatable exportPath exception"); -is($success, 0, "exportAsHtml returns 0 for uncreatable exportPath"); -is($message, "can't create exportPath $inaccessibleDirectory", "exportAsHtml returns correct message for uncreatable exportPath"); + # can't create export path + chmod 0000, $tempDirectory; + + eval { ($success, $message) = $home->exportAsHtml( { userId => 3, depth => 99 } ) }; + is($@, '', "exportAsHtml catches uncreatable exportPath exception"); + is($success, 0, "exportAsHtml returns 0 for uncreatable exportPath"); + is($message, "can't create exportPath $inaccessibleDirectory", "exportAsHtml returns correct message for uncreatable exportPath"); +} # user can't view asset $home->update( { groupIdView => 3 } );