X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Farg_constraints.t;h=cb4d8cf03a24100558a449c8241d1199617e04d8;hp=2a005b72f1b11df1c49d6092daa8fdd87fc74a6d;hb=afa7a6c9f9b0b788c6c165231fbb571a9d8b7a37;hpb=ce3b4f1018499e6625dfe42c25a419cff73d8537 diff --git a/t/arg_constraints.t b/t/arg_constraints.t index 2a005b7..cb4d8cf 100644 --- a/t/arg_constraints.t +++ b/t/arg_constraints.t @@ -43,6 +43,23 @@ BEGIN { } { + package MyApp::Role::Controller; + $INC{'MyApp/Role/Controller.pm'} = __FILE__; + + use Moose::Role; + use MooseX::MethodAttributes::Role; + use MyApp::Types qw/Int Str/; + + sub role_str :Path('role_test') Args(Str) { + my ($self, $c, $arg) = @_; + $c->res->body('role_str'.$arg); + } + + sub role_int :Path('role_test') Args(Int) { + my ($self, $c, $arg) = @_; + $c->res->body('role_int'.$arg); + } + package MyApp::Model::User; $INC{'MyApp/Model/User.pm'} = __FILE__; @@ -70,6 +87,8 @@ BEGIN { use MyApp::Types qw/Tuple Int Str StrMatch ArrayRef UserId User Heart/; extends 'Catalyst::Controller'; + with 'MyApp::Role::Controller'; + sub user :Local Args(UserId) { my ($self, $c, $int) = @_; @@ -476,4 +495,17 @@ SKIP: { } +# Test Roles + +{ + my $res = request '/role_test/1'; + is $res->content, 'role_int1'; +} + +{ + my $res = request '/role_test/a'; + is $res->content, 'role_stra'; +} + + done_testing;