Skip to content

Commit

Permalink
fixed small bug in Mojo::Asset::File and improved tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 16, 2012
1 parent 050a25c commit bb2661c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Changes
@@ -1,4 +1,8 @@

3.10 2012-07-17
- Improved tests.
- Fixed small bug in Mojo::Asset::File.

3.09 2012-07-16
- Added spurt function to Mojo::Util.
- Added spurt method to Mojo::ByteStream.
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojo/Asset/File.pm
Expand Up @@ -120,7 +120,8 @@ sub move_to {
my ($self, $to) = @_;

# Windows requires that the handle is closed
close delete $self->{handle};
close $self->handle;
delete $self->{handle};

# Move file and prevent clean up
my $from = $self->path;
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious.pm
Expand Up @@ -34,7 +34,7 @@ has static => sub { Mojolicious::Static->new };
has types => sub { Mojolicious::Types->new };

our $CODENAME = 'Rainbow';
our $VERSION = '3.09';
our $VERSION = '3.10';

# "These old doomsday devices are dangerously unstable.
# I'll rest easier not knowing where they are."
Expand Down
10 changes: 9 additions & 1 deletion t/mojo/asset.t
@@ -1,6 +1,6 @@
use Mojo::Base -strict;

use Test::More tests => 63;
use Test::More tests => 69;

# "And now, in the spirit of the season: start shopping.
# And for every dollar of Krusty merchandise you buy,
Expand Down Expand Up @@ -114,6 +114,10 @@ is $mem->move_to($path)->slurp, 'abc', 'right content';
ok -e $path, 'file exists';
unlink $path;
ok !-e $path, 'file has been cleaned up';
is(Mojo::Asset::Memory->new->move_to($path)->slurp, '', 'no content');
ok -e $path, 'file exists';
unlink $path;
ok !-e $path, 'file has been cleaned up';

# Move file asset to file
$file = Mojo::Asset::File->new;
Expand All @@ -129,6 +133,10 @@ undef $file;
ok -e $path, 'file exists';
unlink $path;
ok !-e $path, 'file has been cleaned up';
is(Mojo::Asset::File->new->move_to($path)->slurp, '', 'no content');
ok -e $path, 'file exists';
unlink $path;
ok !-e $path, 'file has been cleaned up';

# Upgrade
my $asset = Mojo::Asset::Memory->new(max_memory_size => 5, auto_upgrade => 1);
Expand Down

0 comments on commit bb2661c

Please sign in to comment.