Skip to content

Commit

Permalink
mention that the file method can return undef
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 29, 2014
1 parent cfbb272 commit b279513
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Mojolicious/Static.pm
Expand Up @@ -210,8 +210,9 @@ Serve static file for L<Mojolicious::Controller> object.
my $asset = $static->file('../lib/MyApp.pm');
Build L<Mojo::Asset::File> or L<Mojo::Asset::Memory> object for a file,
relative to L</"paths"> or from L</"classes">. Note that this method does not
protect from traversing to parent directories.
relative to L</"paths"> or from L</"classes">, or return C<undef> if it
doesn't exist. Note that this method does not protect from traversing to
parent directories.
my $content = $static->file('foo/bar.html')->slurp;
Expand Down
1 change: 1 addition & 0 deletions t/mojolicious/app.t
Expand Up @@ -57,6 +57,7 @@ is_deeply $t->app->commands->namespaces,
is $t->app, $t->app->commands->app, 'applications are equal';
is $t->app->static->file('hello.txt')->slurp,
"Hello Mojo from a development static file!\n", 'right content';
is $t->app->static->file('does_not_exist.html'), undef, 'no file';
is $t->app->moniker, 'mojolicious_test', 'right moniker';
is $t->app->secrets->[0], $t->app->moniker, 'secret defaults to moniker';
is $t->app->renderer->template_handler(
Expand Down
1 change: 1 addition & 0 deletions t/mojolicious/production_app.t
Expand Up @@ -32,6 +32,7 @@ is_deeply $t->app->commands->namespaces,
is $t->app, $t->app->commands->app, 'applications are equal';
is $t->app->static->file('hello.txt')->slurp,
"Hello Mojo from a static file!\n", 'right content';
is $t->app->static->file('does_not_exist.html'), undef, 'no file';
is $t->app->moniker, 'mojolicious_test', 'right moniker';

# Default namespaces
Expand Down

0 comments on commit b279513

Please sign in to comment.