[Catalyst-commits] r13514 - in Catalyst-Runtime/5.80/trunk/t: aggregate lib lib/ChainedActionsApp lib/ChainedActionsApp/Controller

ferz at dev.catalyst.perl.org ferz at dev.catalyst.perl.org
Sun Aug 22 14:03:36 GMT 2010


Author: ferz
Date: 2010-08-22 15:03:36 +0100 (Sun, 22 Aug 2010)
New Revision: 13514

Added:
   Catalyst-Runtime/5.80/trunk/t/aggregate/unit_dispatcher_chained_action.t
   Catalyst-Runtime/5.80/trunk/t/lib/ChainedActionsApp/
   Catalyst-Runtime/5.80/trunk/t/lib/ChainedActionsApp/Controller/
   Catalyst-Runtime/5.80/trunk/t/lib/ChainedActionsApp/Controller/Root.pm
Log:
Discovered some inconsistency in precedence behavior of chained actions.


Added: Catalyst-Runtime/5.80/trunk/t/aggregate/unit_dispatcher_chained_action.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/unit_dispatcher_chained_action.t	                        (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/unit_dispatcher_chained_action.t	2010-08-22 14:03:36 UTC (rev 13514)
@@ -0,0 +1,13 @@
+# Test case for Chained Actions
+
+#
+
+use strict;
+use warnings;
+use FindBin qw/$Bin/;
+use lib "$Bin/../lib";
+use Catalyst::Test 'ChainedActionsApp';
+use Test::More tests => 2;
+
+content_like('/', qr/Application Home Page/, 'Application home');
+content_like('/account/123', qr/This is account 123/, 'account');

Added: Catalyst-Runtime/5.80/trunk/t/lib/ChainedActionsApp/Controller/Root.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/ChainedActionsApp/Controller/Root.pm	                        (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/lib/ChainedActionsApp/Controller/Root.pm	2010-08-22 14:03:36 UTC (rev 13514)
@@ -0,0 +1,112 @@
+package ChainedActionsApp::Controller::Root;
+use Moose;
+use namespace::autoclean;
+
+BEGIN { extends 'Catalyst::Controller' }
+
+#
+# Sets the actions in this controller to be registered with no prefix
+# so they function identically to actions created in MyApp.pm
+#
+__PACKAGE__->config(namespace => '');
+
+=head1 NAME
+
+test_chained::Controller::Root - Root Controller for test_chained
+
+=head1 DESCRIPTION
+
+[enter your description here]
+
+=head1 METHODS
+
+=head2 setup
+
+This is the C<setup> method that initializes the request. Any matching action
+will go through this, so it is an application-wide automatically executed
+action. For more information, see L<Catalyst::DispatchType::Chained>
+
+=cut
+
+sub setup : Chained('/') PathPart('') CaptureArgs(0) {
+    my ( $self, $c ) = @_;
+    # Common things here are to check for ACL and setup global contexts
+}
+
+sub home : Chained('setup') PathPart('') Args(0) {
+    my($self,$c) = @_;
+    $c->response->body( "Application Home Page" );
+}
+
+=head2 home_base
+
+     Args:
+       project_id
+       project_title
+
+=cut
+
+sub home_base : Chained('setup') PathPart('') CaptureArgs(2) {
+    my($self,$c,$proj_id,$title) = @_;
+    $c->stash->{project_id}=$proj_id;
+}
+
+sub hpages : Chained('home_base') PathPart('') Args(0) {
+    my($self,$c) = @_;
+    $c->response->body( "List project " . $c->stash->{project_id} . " pages");
+}
+
+sub hpage : Chained('home_base') PathPart('') Args(2) {
+    my($self,$c,$page_id, $pagetitle) = @_;
+    $c->response->body( "This is $pagetitle page of " . $c->stash->{project_id} . " project" );
+}
+
+sub no_account : Chained('setup') PathPart('account') Args(0) {
+    my($self,$c) = @_;
+    $c->response->body( "New account o login" );
+}
+
+sub account_base : Chained('setup') PathPart('account') CaptureArgs(1) {
+    my($self,$c,$acc_id) = @_;
+    $c->stash({account_id=>$acc_id});
+}
+
+sub account : Chained('account_base') PathPart('') Args(0) {
+    my($self,$c,$acc) = @_;
+    $c->response->body( "This is account " . $c->stash->{account_id} );
+}
+
+=head2 default
+
+Standard 404 error page
+
+=cut
+
+sub default : Chained('setup') PathPart('') Args() {
+    my ( $self, $c ) = @_;
+    $c->response->body( 'Page not found' );
+    $c->response->status(404);
+}
+
+=head2 end
+
+Attempt to render a view, if needed.
+
+=cut
+
+sub end : ActionClass('RenderView') {}
+
+=head1 AUTHOR
+
+Ferruccio Zamuner
+
+=head1 LICENSE
+
+This library is free software. You can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+__PACKAGE__->meta->make_immutable;
+
+1;




More information about the Catalyst-commits mailing list