Skip to content

Commit

Permalink
fixed bridge bug in MojoX::Routes::Match
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 25, 2010
1 parent 84070b6 commit d1c957d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Changes
Expand Up @@ -24,6 +24,8 @@ This file documents the revision history for Perl extension Mojolicious.
- Improved routes by making the leading slash optional.
- Converted README to markdown. (memowe)
- Fixed connection keep alive with epoll.
- Fixed bridge bug in MojoX::Routes::Match.
(Oleg Zhelo, Dmitry Konstantinov)
- Fixed argument handling of Mojo::Template blocks. (afresh1)
- Fixed a stash localization bug. (und3f)
- Fixed Mojo::Log to use flock to sync log file writing.
Expand Down
2 changes: 1 addition & 1 deletion lib/MojoX/Routes/Match.pm
Expand Up @@ -100,7 +100,7 @@ sub match {
$self->{_path} = $path;

# Reset stack
if ($r->parent) { $self->stack($snapshot) }
if ($r->parent) { $self->stack([@$snapshot]) }
else {
$self->captures({});
$self->stack([]);
Expand Down
2 changes: 2 additions & 0 deletions lib/Mojolicious.pm
Expand Up @@ -633,6 +633,8 @@ Maxim Vuets
Mirko Westermeier
Oleg Zhelo
Pascal Gaudette
Pedro Melo
Expand Down
24 changes: 23 additions & 1 deletion t/mojox/routes/routes.t
Expand Up @@ -5,7 +5,7 @@
use strict;
use warnings;

use Test::More tests => 184;
use Test::More tests => 193;

use Mojo::Transaction::HTTP;

Expand Down Expand Up @@ -127,6 +127,13 @@ $r->route('/method/post_get')->via(qw/POST get/)
# /simple/form
$r->route('/simple/form')->to('test-test#test');

# /edge/gift
my $edge = $r->route('/edge');
my $auth = $edge->bridge('/auth')->to('auth#check');
$auth->route('/about/')->to('pref#about');
$auth->bridge->to('album#allow')->route('/album/create/')->to('album#create');
$auth->route('/gift/')->to('gift#index');

# Make sure stash stays clean
my $tx = Mojo::Transaction::HTTP->new;
$tx->req->method('GET');
Expand Down Expand Up @@ -476,3 +483,18 @@ is($m->stack->[0]->{action}, 'test');
is($m->stack->[0]->{format}, undef);
is($m->url_for, '/simple/form');
is(@{$m->stack}, 1);

# Special edge case with nested bridges
$tx = Mojo::Transaction::HTTP->new;
$tx->req->method('GET');
$tx->req->url->parse('/edge/auth/gift');
$m = MojoX::Routes::Match->new($tx)->match($r);
is($m->stack->[0]->{controller}, 'auth');
is($m->stack->[0]->{action}, 'check');
is($m->stack->[0]->{format}, undef);
is($m->stack->[1]->{controller}, 'gift');
is($m->stack->[1]->{action}, 'index');
is($m->stack->[1]->{format}, undef);
is($m->stack->[2], undef);
is($m->url_for, '/edge/auth/gift');
is(@{$m->stack}, 2);

0 comments on commit d1c957d

Please sign in to comment.