From: John Napiorkowski Date: Tue, 31 Aug 2010 02:46:53 +0000 (-0400) Subject: fixed regression with action_role namespaces being lost (created last release) and... X-Git-Tag: 0.014~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalystX-Declare.git;a=commitdiff_plain;h=12b853ff6a6c44408b976ac6efcfe9f0e5a99e38 fixed regression with action_role namespaces being lost (created last release) and added some tests to prevent in the future --- diff --git a/lib/CatalystX/Declare/Controller/ActionPreparation.pm b/lib/CatalystX/Declare/Controller/ActionPreparation.pm index 66052fe..daf4c9d 100644 --- a/lib/CatalystX/Declare/Controller/ActionPreparation.pm +++ b/lib/CatalystX/Declare/Controller/ActionPreparation.pm @@ -52,16 +52,22 @@ role CatalystX::Declare::Controller::ActionPreparation { $self->_ensure_applied_dispatchtype_roles; } + around gather_action_roles(%args) { return ( $self->$orig(%args), - @{ delete($args{attributes}{CatalystX_Declarative_ActionRoles}) || [] }, + (map { + $self->_qualify_class_name(ActionRole => $_); + #$self->_expand_role_shortname($_); + } @{ delete($args{attributes}{CatalystX_Declarative_ActionRoles}) || [] }), + @{ delete($args{attributes}{CatalystX_Declarative_DefaultActionRoles}) || [] }, ); } around create_action (%args) { my $action = $self->$orig(%args); + ## TODO Do we really need this anymore? return $action if $args{attributes}{Private}; diff --git a/lib/CatalystX/Declare/Keyword/Action.pm b/lib/CatalystX/Declare/Keyword/Action.pm index eb4f20e..17152cf 100644 --- a/lib/CatalystX/Declare/Keyword/Action.pm +++ b/lib/CatalystX/Declare/Keyword/Action.pm @@ -300,7 +300,7 @@ class CatalystX::Declare::Keyword::Action { $attrs->{Signature} = $proto; $attrs->{Action} = []; - push @{ $attrs->{CatalystX_Declarative_ActionRoles} ||= [] }, CatchValidationError; + push @{ $attrs->{CatalystX_Declarative_DefaultActionRoles} ||= [] }, CatchValidationError; # default chained base to the global under var, to be resolved at runtime $attrs->{Chained} ||= UNDER_VAR; diff --git a/t/100_complex.t b/t/100_complex.t index b3ae43c..95be111 100644 --- a/t/100_complex.t +++ b/t/100_complex.t @@ -73,4 +73,7 @@ is get('/actionparams/second'), 'action_args_second: 200,201', 'actionrole with is get('/actionparams/third'), 'action_args_third: 300,301', 'actionrole with params (part three)'; is get('/actionparams/forth'), 'action_args_forth: 400,1,401,2', 'actionrole with params (part four)'; +is get('/actionparams/first_app_ns'), 'action_args_first: 100,101', 'actionrole with params (from App NS)'; +is get('/actionparams/first_cat_ns'), 'action_args_first: 100,101', 'actionrole with params (from Cat NS)'; + done_testing; diff --git a/t/lib/Catalyst/ActionRole/hasActionParams_CatNS.pm b/t/lib/Catalyst/ActionRole/hasActionParams_CatNS.pm new file mode 100644 index 0000000..f477dc3 --- /dev/null +++ b/t/lib/Catalyst/ActionRole/hasActionParams_CatNS.pm @@ -0,0 +1,16 @@ +package Catalyst::ActionRole::hasActionParams_CatNS; +use Moose::Role; + +has [qw/p1 p2/] => (is=>'ro', lazy_build=>1); + +sub _build_p1 { + my $self = shift @_; + return join ',', @{$self->attributes->{p1}}; +} + +sub _build_p2 { + my $self = shift @_; + return join ',', @{$self->attributes->{p2}}; +} + +1; diff --git a/t/lib/TestApp/ActionRole/hasActionParams_AppNS.pm b/t/lib/TestApp/ActionRole/hasActionParams_AppNS.pm new file mode 100644 index 0000000..5b9ceae --- /dev/null +++ b/t/lib/TestApp/ActionRole/hasActionParams_AppNS.pm @@ -0,0 +1,12 @@ +use CatalystX::Declare; +namespace TestApp; +role ::ActionRole::hasActionParams_AppNS { + has [qw/p1 p2/] => (is=>'ro', lazy_build=>1); + method _build_p1 { + join ',', @{$self->attributes->{p1}}; + } + method _build_p2 { + join ',', @{$self->attributes->{p2}}; + } +} + diff --git a/t/lib/TestApp/Controller/ActionParams.pm b/t/lib/TestApp/Controller/ActionParams.pm index 4b524a7..8208d04 100644 --- a/t/lib/TestApp/Controller/ActionParams.pm +++ b/t/lib/TestApp/Controller/ActionParams.pm @@ -19,15 +19,15 @@ controller ::Controller::ActionParams { as 'actionparams'; action first under base - with hasActionParams(p1=>100,p2=>101) - is final { + with hasActionParams(p1=>100,p2=>101) + is final { my $p1 = $ctx->controller->action_for('first')->p1; my $p2 = $ctx->controller->action_for('first')->p2; $ctx->response->body("action_args_first: $p1,$p2"); } action second under base - with hasActionParams({p1=>200,p2=>201}) + with hasActionParams({p1=>200,p2=>201}) is final { my $p1 = $ctx->controller->action_for('second')->p1; my $p2 = $ctx->controller->action_for('second')->p2; @@ -53,5 +53,22 @@ controller ::Controller::ActionParams { my $p2 = $ctx->controller->action_for('forth')->p2; $ctx->response->body("action_args_forth: $p1,$p2"); } + + action first_app_ns under base + with hasActionParams_AppNS(p1=>100,p2=>101) + is final { + my $p1 = $ctx->controller->action_for('first')->p1; + my $p2 = $ctx->controller->action_for('first')->p2; + $ctx->response->body("action_args_first: $p1,$p2"); + } + + action first_cat_ns under base + with hasActionParams_CatNS(p1=>100,p2=>101) + is final { + my $p1 = $ctx->controller->action_for('first')->p1; + my $p2 = $ctx->controller->action_for('first')->p2; + $ctx->response->body("action_args_first: $p1,$p2"); + } + }