diff --git a/lib/WebGUI/Storage.pm b/lib/WebGUI/Storage.pm index 237f835a3..b80cd64f5 100644 --- a/lib/WebGUI/Storage.pm +++ b/lib/WebGUI/Storage.pm @@ -458,11 +458,10 @@ sub delete { my $path = $self->getPath; if ($path) { - rmtree($path) if ($path); + rmtree($path) if (-d $path); foreach my $subDir ($self->{_part1}.'/'.$self->{_part2}, $self->{_part1}) { my $uDir = $self->session->config->get('uploadsPath') . '/' . $subDir; - opendir my ($DH), $uDir; - if (defined $DH) { + if (opendir my $DH, $uDir) { my @dirs = grep { !/^\.+$/ } readdir($DH); if (scalar @dirs == 0) { rmtree($uDir); @@ -661,14 +660,16 @@ The name of the file to get the icon for. =cut sub getFileIconUrl { - my $self = shift; - my $filename = shift; - my $extension = $self->getFileExtension($filename); - my $path = $self->session->config->get("extrasPath").'/fileIcons/'.$extension.".gif"; - if (-e $path && $extension) { - return $self->session->url->extras("fileIcons/".$extension.".gif"); - } - return $self->session->url->extras("fileIcons/unknown.gif"); + my $self = shift; + my $filename = shift; + my $extension = $self->getFileExtension($filename); + if ($extension) { + my $path = $self->session->config->get("extrasPath").'/fileIcons/'.$extension.".gif"; + if (-e $path) { + return $self->session->url->extras("fileIcons/".$extension.".gif"); + } + } + return $self->session->url->extras("fileIcons/unknown.gif"); } @@ -941,6 +942,7 @@ sub tar { my $self = shift; my $filename = shift; my $temp = shift || WebGUI::Storage->createTemp($self->session); + my $originalDir = cwd; chdir $self->getPath or croak 'Unable to chdir to ' . $self->getPath . ": $!"; my @files = (); find(sub { push(@files, $File::Find::name)}, "."); @@ -948,11 +950,11 @@ sub tar { my $tar = Archive::Tar->new(); $tar->add_files(@files); $tar->write($temp->getPath($filename),1); - } else { Archive::Tar->create_archive($temp->getPath($filename),1,@files); } + chdir $originalDir; return $temp; } diff --git a/t/Asset/Redirect/mech.t b/t/Asset/Redirect/mech.t index 84e04a4cf..e59724879 100644 --- a/t/Asset/Redirect/mech.t +++ b/t/Asset/Redirect/mech.t @@ -152,11 +152,14 @@ $mech->content_contains( $testContent, "We made it to the snippet through the lo $response = $mech->res->previous; ok( $response, 'There were at least two requests' ); -is( - $response->headers->header('location'), - $redirectToUrl . ';' . $extraParams, - "We were redirected to the right URL with forwarded query params", -); +TODO: { + local $TODO = 'Add forwarding of query parameters to Redirect asset'; + is( + $response->headers->header('location'), + $redirectToUrl . ';' . $extraParams, + "We were redirected to the right URL with forwarded query params", + ); +}; #---------------------------------------------------------------------------- diff --git a/t/Storage.t b/t/Storage.t index a7041b7d9..fc8447024 100644 --- a/t/Storage.t +++ b/t/Storage.t @@ -21,9 +21,12 @@ use File::Spec; use Test::More; use Test::Deep; use Test::MockObject; +use Cwd; my $session = WebGUI::Test->session; +my $cwd = Cwd::cwd(); + my ($extensionTests, $fileIconTests) = setupDataDrivenTests($session); my $numTests = 82; # increment this value for each test you create @@ -400,10 +403,7 @@ foreach my $iconTest (@{ $fileIconTests }) { # #################################################### -TODO: { - local $TODO = 'Write a test to ensure our CWD remains the same after all these calls to storage'; - ok(0,'CWD must remain the same after addFileFromFilesystem, tar, untar, etc...'); -}; +is($cwd, Cwd::cwd(), 'CWD must remain the same after addFileFromFilesystem, tar, untar, etc...'); #################################################### #