Skip to content

Commit

Permalink
fixed embedded application bug that prevented around_dispatch hook fr…
Browse files Browse the repository at this point in the history
…om working correctly (closes #408)
  • Loading branch information
kraih committed Nov 2, 2012
1 parent 041ac12 commit 7546032
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Changes
@@ -1,6 +1,8 @@

3.55 2012-11-02
- Improved tests.
- Fixed embedded application bug that prevented around_dispatch hook from
working correctly.

3.54 2012-11-01
- Added next and previous methods to Mojo::DOM.
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Routes.pm
Expand Up @@ -128,6 +128,7 @@ sub _controller {
weaken $r->parent($c->match->endpoint)->{parent} unless $r->parent;
}
$app->$sub($c);
$c->stash->{'mojo.routed'}++;
}

# Action
Expand All @@ -136,9 +137,8 @@ sub _controller {
$log->debug(qq{Routing to controller "$class" and action "$method".});

# Try to call action
my $stash = $c->stash;
if (my $sub = $app->can($method)) {
$stash->{'mojo.routed'}++ unless $staging;
$c->stash->{'mojo.routed'}++ unless $staging;
$continue = $app->$sub;
}

Expand Down
3 changes: 3 additions & 0 deletions t/mojolicious/embedded_lite_app.t
Expand Up @@ -237,6 +237,9 @@ $t->get_ok('/x/♥/url/☃')->status_is(200)
# GET /y/1 (full secondary external application)
$t->get_ok('/y/1')->status_is(200)->content_is("works 4!\nInsecure too!");

# GET /y/1/2 (full secondary external application)
$t->get_ok('/y/1/2')->status_is(404);

# GET /y/♥ (full secondary external application)
$t->get_ok('/y/♥')->status_is(200)->content_is("works 3!\nInsecure too!");

Expand Down
7 changes: 7 additions & 0 deletions t/mojolicious/external/myapp2.pl
@@ -1,10 +1,17 @@
#!/usr/bin/env perl

use Mojolicious::Lite;
use Mojo::IOLoop;

# Default for config file tests
app->defaults(secret => 'Insecure too!');

# Delay dispatching
hook around_dispatch => sub {
my ($next, $c) = @_;
Mojo::IOLoop->timer(0 => sub { $next->() });
};

# GET /
get '/' => sub {
my $self = shift;
Expand Down

0 comments on commit 7546032

Please sign in to comment.