fixed regression with action_role namespaces being lost (created last release) and...
John Napiorkowski [Tue, 31 Aug 2010 02:46:53 +0000 (22:46 -0400)]
lib/CatalystX/Declare/Controller/ActionPreparation.pm
lib/CatalystX/Declare/Keyword/Action.pm
t/100_complex.t
t/lib/Catalyst/ActionRole/hasActionParams_CatNS.pm [new file with mode: 0644]
t/lib/TestApp/ActionRole/hasActionParams_AppNS.pm [new file with mode: 0644]
t/lib/TestApp/Controller/ActionParams.pm

index 66052fe..daf4c9d 100644 (file)
@@ -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};
 
index eb4f20e..17152cf 100644 (file)
@@ -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;
index b3ae43c..95be111 100644 (file)
@@ -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 (file)
index 0000000..f477dc3
--- /dev/null
@@ -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 (file)
index 0000000..5b9ceae
--- /dev/null
@@ -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}};
+    }
+}
+
index 4b524a7..8208d04 100644 (file)
@@ -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");
+    }
+
 }