Skip to content

Commit

Permalink
custom names have a higher precedence
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 20, 2014
1 parent 4b9fc41 commit 40a3368
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/Mojolicious/Routes/Route.pm
Expand Up @@ -24,6 +24,7 @@ sub AUTOLOAD {

sub add_child {
my ($self, $route) = @_;
$self->root->flush;
weaken $route->remove->parent($self)->{parent};
push @{$self->children}, $route;
return $self;
Expand Down
9 changes: 3 additions & 6 deletions t/mojolicious/routes.t
Expand Up @@ -197,17 +197,14 @@ $r->route('/missing/too/*', '' => ['test'])
->to('missing#too', '' => 'missing');

# Cached lookup
is $r->find('fast'), undef, 'fastest route not found';
is $r->lookup('fast'), undef, 'fastest route not found';
my $fast = $r->route('/fast');
is $r->find('fast'), $fast, 'fast route found';
is $r->lookup('fast'), $fast, 'fast route found';
my $faster = $r->route('/faster')->name('fast');
is $r->find('fast'), $faster, 'faster route found';
is $r->lookup('fast'), $fast, 'fast route found';
is $r->find('fastest'), undef, 'fastest route not found';
is $r->lookup('fastest'), undef, 'fastest route not found';
my $fastest = $r->route('/fastest');
is $r->find('fastest'), $fastest, 'fastest route found';
is $r->lookup('fastest'), $fastest, 'fastest route found';
is $r->lookup('fast'), $faster, 'fast route found';

# Make sure stash stays clean
my $c = Mojolicious::Controller->new;
Expand Down

0 comments on commit 40a3368

Please sign in to comment.