Skip to content

Commit

Permalink
fixed small route block bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 22, 2011
1 parent 6dea64e commit f659062
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,6 +1,6 @@
This file documents the revision history for Perl extension Mojolicious.

1.99 2011-09-21 00:00:00
1.99 2011-09-22 00:00:00
- Deprecated direct hash access to the flash in
Mojolicious::Controller.
- Added EXPERIMENTAL routes function to Mojolicious::Lite.
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojolicious/Lite.pm
Expand Up @@ -53,7 +53,8 @@ sub import {
*{"${caller}::routes"} = sub (&) {
my $old = $root;
$_[0]->($root = $routes);
$root = $old;
$routes = $root;
$root = $old;
};
*{"${caller}::websocket"} = sub { $routes->websocket(@_) };

Expand Down
29 changes: 28 additions & 1 deletion t/mojolicious/lite_app.t
Expand Up @@ -10,7 +10,7 @@ BEGIN {
$ENV{MOJO_MODE} = 'development';
}

use Test::More tests => 925;
use Test::More tests => 934;

# Pollution
123 =~ m/(\d+)/;
Expand Down Expand Up @@ -794,6 +794,24 @@ routes {
};
};

# Authentication block
routes {

# Check "ok" parameter
under sub {
my $self = shift;
return 1 if $self->req->param('ok');
$self->render(text => "You're not ok.");
return;
};

# GET /authblock
get '/authblock' => {text => "You're ok."};
};

# GET /noauthblock
get '/noauthblock' => {inline => 'Whatever <%= $foo %>.'};

# Oh Fry, I love you more than the moon, and the stars,
# and the POETIC IMAGE NUMBER 137 NOT FOUND
my $t = Test::Mojo->new;
Expand Down Expand Up @@ -1882,6 +1900,15 @@ $t->get_ok('/block/nested/whatever')->status_is(200)
# GET /block/nested/something
$t->get_ok('/block/nested/something')->status_is(404);

# GET /authblock?ok=1
$t->get_ok('/authblock?ok=1')->status_is(200)->content_is("You're ok.");

# GET /authblock
$t->get_ok('/authblock')->status_is(200)->content_is("You're not ok.");

# GET /noauthblock
$t->get_ok('/noauthblock')->status_is(200)->content_is("Whatever one.\n");

# GET /captures/foo/bar
$t->get_ok('/captures/foo/bar')->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')
Expand Down

0 comments on commit f659062

Please sign in to comment.