From: Tomas Doran Date: Tue, 15 Jun 2010 21:17:32 +0000 (+0000) Subject: Commit standalone test, test which makes the TestApp blow up and the nasty workaround X-Git-Tag: 5.80025~2^2~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=10e970e4efdf69f9cd023b93016514f7668b54f7 Commit standalone test, test which makes the TestApp blow up and the nasty workaround --- diff --git a/lib/Catalyst/Controller.pm b/lib/Catalyst/Controller.pm index fbc8768..2f4185f 100644 --- a/lib/Catalyst/Controller.pm +++ b/lib/Catalyst/Controller.pm @@ -225,7 +225,7 @@ sub register_action_methods { foreach my $method (@methods) { my $name = $method->name; - my $attributes = $method->attributes; + my $attributes = $method->can('attributes') ? $method->attributes : []; my $attrs = $self->_parse_attrs( $c, $name, @{ $attributes } ); if ( $attrs->{Private} && ( keys %$attrs > 1 ) ) { $c->log->debug( 'Bad action definition "' diff --git a/t/lib/TestApp/Controller/Moose/NoAttributes.pm b/t/lib/TestApp/Controller/Moose/NoAttributes.pm new file mode 100644 index 0000000..7770816 --- /dev/null +++ b/t/lib/TestApp/Controller/Moose/NoAttributes.pm @@ -0,0 +1,16 @@ +package TestApp::Controller::Moose::NoAttributes; +use Moose; +extends qw/Catalyst::Controller/; + +__PACKAGE__->config( + actions => { + test => { Local => undef } + } +); + +sub test { +} + +no Moose; +1; + diff --git a/t/unit_core_methodattributes_method_metaclass_on_subclasses.t b/t/unit_core_methodattributes_method_metaclass_on_subclasses.t new file mode 100644 index 0000000..32e8037 --- /dev/null +++ b/t/unit_core_methodattributes_method_metaclass_on_subclasses.t @@ -0,0 +1,27 @@ +use strict; +use Test::More; + +{ + package NoAttributes::CT; + use Moose; + BEGIN { extends qw/Catalyst::Controller/; }; + + sub test {} +} +{ + package NoAttributes::RT; + use Moose; + extends qw/Catalyst::Controller/; + + sub test {} +} + +foreach my $class (qw/ CT RT /) { + my $class_name = 'NoAttributes::' . $class; + my $meta = $class_name->meta; + my $meth = $meta->find_method_by_name('test'); + ok $meth->can('attributes'), 'method metaclass has ->attributes method for ' . $class;; +} + +done_testing; +