Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
improved to method in Mojolicious::Routes::Route to allow controller …
…classes containing "::" in shortcuts
  • Loading branch information
kraih committed Oct 10, 2012
1 parent 0d819ad commit d429e82
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Changes
@@ -1,4 +1,8 @@

3.46 2012-10-11
- Improved to method in Mojolicious::Routes::Route to allow controller
classes containing "::" in shortcuts.

3.45 2012-10-10
- Added multi_accept attribute to Mojo::IOLoop.
- Added multi_accept attribute to Mojo::IOLoop::Server.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious.pm
Expand Up @@ -38,7 +38,7 @@ has static => sub { Mojolicious::Static->new };
has types => sub { Mojolicious::Types->new };

our $CODENAME = 'Rainbow';
our $VERSION = '3.45';
our $VERSION = '3.46';

sub AUTOLOAD {
my $self = shift;
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Routes/Route.pm
Expand Up @@ -194,7 +194,7 @@ sub to {
}

# Controller and action
elsif ($shortcut =~ /^([\w\-]+)?\#(\w+)?$/) {
elsif ($shortcut =~ /^([\w\-:]+)?\#(\w+)?$/) {
$defaults->{controller} = $1 if defined $1;
$defaults->{action} = $2 if defined $2;
}
Expand Down
8 changes: 7 additions & 1 deletion t/mojolicious/app.t
Expand Up @@ -7,7 +7,7 @@ BEGIN {
$ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
}

use Test::More tests => 339;
use Test::More tests => 344;

use FindBin;
use lib "$FindBin::Bin/lib";
Expand Down Expand Up @@ -226,6 +226,12 @@ $t->get_ok('/test6' => {'X-Test' => 'Hi there!'})->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')->content_is('/test6');

# MojoliciousTest::Foo::Bar::test (controller class)
$t->get_ok('/test7' => {'X-Test' => 'Hi there!'})->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->content_is('Class works!');

# 404
$t->get_ok('/' => {'X-Test' => 'Hi there!'})->status_is(404)
->header_is(Server => 'Mojolicious (Perl)')
Expand Down
3 changes: 3 additions & 0 deletions t/mojolicious/lib/MojoliciousTest.pm
Expand Up @@ -118,6 +118,9 @@ sub startup {
action => 'test'
);

# /test7 (controller class)
$r->route('/test7')->to('Foo::Bar#test');

# /withblock (template with blocks)
$r->route('/withblock')->to('foo#withblock');

Expand Down
2 changes: 2 additions & 0 deletions t/mojolicious/lib/MojoliciousTest/Foo/Bar.pm
Expand Up @@ -3,4 +3,6 @@ use Mojolicious::Controller -base;

sub index {1}

sub test { shift->render(text => 'Class works!') }

1;

0 comments on commit d429e82

Please sign in to comment.