[Catalyst-commits] r10466 - in
Catalyst-Runtime/5.80/branches/namespace_handling_refactor: .
lib/Catalyst t/aggregate t/lib/TestApp/Controller/Action
mo at dev.catalyst.perl.org
mo at dev.catalyst.perl.org
Sun Jun 7 11:14:23 GMT 2009
Author: mo
Date: 2009-06-07 11:14:23 +0000 (Sun, 07 Jun 2009)
New Revision: 10466
Modified:
Catalyst-Runtime/5.80/branches/namespace_handling_refactor/TODO
Catalyst-Runtime/5.80/branches/namespace_handling_refactor/lib/Catalyst/Controller.pm
Catalyst-Runtime/5.80/branches/namespace_handling_refactor/t/aggregate/live_component_controller_action_path.t
Catalyst-Runtime/5.80/branches/namespace_handling_refactor/t/lib/TestApp/Controller/Action/Path.pm
Log:
controller actions without attributes which are defined via config
Modified: Catalyst-Runtime/5.80/branches/namespace_handling_refactor/TODO
===================================================================
--- Catalyst-Runtime/5.80/branches/namespace_handling_refactor/TODO 2009-06-07 03:26:14 UTC (rev 10465)
+++ Catalyst-Runtime/5.80/branches/namespace_handling_refactor/TODO 2009-06-07 11:14:23 UTC (rev 10466)
@@ -7,4 +7,6 @@
* Catalyst::Controller::_parse_ActionClass_attr # DONE
* Catalyst::Dispatcher::_load_dispatch_types # DONE
* Catalyst::setup_plugins # DONE
- to use the same namespacing method
\ No newline at end of file
+ to use the same namespacing method
+
+- Ok, so can you add tests for ->config(actions => { foo => { ActionClass => '+Bar' }});
\ No newline at end of file
Modified: Catalyst-Runtime/5.80/branches/namespace_handling_refactor/lib/Catalyst/Controller.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/namespace_handling_refactor/lib/Catalyst/Controller.pm 2009-06-07 03:26:14 UTC (rev 10465)
+++ Catalyst-Runtime/5.80/branches/namespace_handling_refactor/lib/Catalyst/Controller.pm 2009-06-07 11:14:23 UTC (rev 10466)
@@ -178,13 +178,28 @@
sub get_action_methods {
my $self = shift;
my $meta = find_meta($self);
- confess("Metaclass for " . ref($meta) ." for " . $meta->name
- . " cannot support register_actions.")
- unless $meta->can('get_nearest_methods_with_attributes');
+ confess("Metaclass for "
+ . ref($meta) . " for "
+ . $meta->name
+ . " cannot support register_actions." )
+ unless $meta->can('get_nearest_methods_with_attributes');
my @methods = $meta->get_nearest_methods_with_attributes;
+
+ # actions specified via config are also action_methods
+ push(
+ @methods,
+ map {
+ $meta->get_method($_)
+ || confess( 'Action "'
+ . $_
+ . '" is not available from controller '
+ . ( ref $self ) )
+ } keys %{ $self->_controller_actions }
+ ) if ( ref $self );
return @methods;
}
+
sub register_actions {
my ( $self, $c ) = @_;
$self->register_action_methods( $c, $self->get_action_methods );
@@ -199,7 +214,7 @@
foreach my $method (@methods) {
my $name = $method->name;
my $attributes = $method->attributes;
- next unless $attributes;
+ #next unless $attributes;
my $attrs = $self->_parse_attrs( $c, $name, @{ $attributes } );
if ( $attrs->{Private} && ( keys %$attrs > 1 ) ) {
$c->log->debug( 'Bad action definition "'
Modified: Catalyst-Runtime/5.80/branches/namespace_handling_refactor/t/aggregate/live_component_controller_action_path.t
===================================================================
--- Catalyst-Runtime/5.80/branches/namespace_handling_refactor/t/aggregate/live_component_controller_action_path.t 2009-06-07 03:26:14 UTC (rev 10465)
+++ Catalyst-Runtime/5.80/branches/namespace_handling_refactor/t/aggregate/live_component_controller_action_path.t 2009-06-07 11:14:23 UTC (rev 10466)
@@ -10,7 +10,7 @@
BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
-use Test::More tests => 36*$iters;
+use Test::More tests => 42*$iters;
use Catalyst::Test 'TestApp';
if ( $ENV{CAT_BENCHMARK} ) {
@@ -142,4 +142,22 @@
'Content is a serialized Catalyst::Request'
);
}
+
+ {
+ ok( my $response = request('http://localhost/action/path/six'), 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->content_type, 'text/plain', 'Response Content-Type' );
+ is( $response->header('X-Catalyst-Action'),
+ 'action/path/six', 'Test Action' );
+ is(
+ $response->header('X-Test-Class'),
+ 'TestApp::Controller::Action::Path',
+ 'Test Class'
+ );
+ like(
+ $response->content,
+ qr/^bless\( .* 'Catalyst::Request' \)$/s,
+ 'Content is a serialized Catalyst::Request'
+ );
+ }
}
Modified: Catalyst-Runtime/5.80/branches/namespace_handling_refactor/t/lib/TestApp/Controller/Action/Path.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/namespace_handling_refactor/t/lib/TestApp/Controller/Action/Path.pm 2009-06-07 03:26:14 UTC (rev 10465)
+++ Catalyst-Runtime/5.80/branches/namespace_handling_refactor/t/lib/TestApp/Controller/Action/Path.pm 2009-06-07 11:14:23 UTC (rev 10466)
@@ -7,6 +7,7 @@
actions => {
'one' => { 'Path' => [ 'a path with spaces' ] },
'two' => { 'Path' => "åäö" },
+ 'six' => { 'Local' => undef },
},
);
@@ -35,4 +36,9 @@
$c->forward('TestApp::View::Dump::Request');
}
+sub six {
+ my ( $self, $c ) = @_;
+ $c->forward('TestApp::View::Dump::Request');
+}
+
1;
More information about the Catalyst-commits
mailing list