Commit standalone test, test which makes the TestApp blow up and the nasty workaround
Tomas Doran [Tue, 15 Jun 2010 21:17:32 +0000 (21:17 +0000)]
lib/Catalyst/Controller.pm
t/lib/TestApp/Controller/Moose/NoAttributes.pm [new file with mode: 0644]
t/unit_core_methodattributes_method_metaclass_on_subclasses.t [new file with mode: 0644]

index fbc8768..2f4185f 100644 (file)
@@ -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 (file)
index 0000000..7770816
--- /dev/null
@@ -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 (file)
index 0000000..32e8037
--- /dev/null
@@ -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;
+