Skip to content

Commit

Permalink
test stash snapshot for not found page
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 11, 2014
1 parent c9392e1 commit e8408b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 1 addition & 2 deletions lib/Mojolicious/Controller.pm
Expand Up @@ -420,8 +420,7 @@ sub _development {
status => $page eq 'exception' ? 500 : 404
};
$options->{exception} = $e if $page eq 'exception';
my $inline
= $renderer->_bundled($mode eq 'development' ? 'development' : $page);
my $inline = $renderer->_bundled($mode eq 'development' ? $mode : $page);
return $self if _fallbacks($self, $options, $page, $inline);
_fallbacks($self, {%$options, format => 'html'}, $page, $inline);
return $self;
Expand Down
7 changes: 4 additions & 3 deletions t/mojolicious/exception_lite_app.t
Expand Up @@ -24,8 +24,9 @@ helper dead_helper => sub { die "dead helper!\n" };
# Custom rendering for missing "txt" template
hook before_render => sub {
my ($self, $args) = @_;
$args->{text} = 'Missing template.'
if ($args->{template} // '') eq 'not_found' && $args->{format} eq 'txt';
return unless ($args->{template} // '') eq 'not_found';
my $format = $self->stash('snapshot')->{format};
$args->{text} = "Missing $format template." if $args->{format} eq 'txt';
};

# Custom exception rendering for "txt"
Expand Down Expand Up @@ -215,7 +216,7 @@ $t->get_ok('/missing_template.json')->status_is(404)
# Missing template with custom rendering
$t->get_ok('/missing_template.txt')->status_is(404)
->content_type_is('text/plain;charset=UTF-8')
->content_is('Missing template.');
->content_is('Missing txt template.');

# Missing template (failed rendering)
$t->get_ok('/missing_template/too')->status_is(404)
Expand Down

0 comments on commit e8408b4

Please sign in to comment.