From: Tomas Doran Date: Sun, 26 Apr 2009 11:11:35 +0000 (+0000) Subject: Somewhat, but not much more sane. There are still bugs here, but this _should_ fix... X-Git-Tag: 5.80003~29 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=cf37d21a258273df337d7c3d9214b286713ec9ca Somewhat, but not much more sane. There are still bugs here, but this _should_ fix karpet's issue --- diff --git a/Changes b/Changes index 595db57..3f4ad7f 100644 --- a/Changes +++ b/Changes @@ -8,6 +8,11 @@ AGGREGATE_TESTS environment variable is set and a recent Test::Aggregate is available. (rafl) - POD formatting fix for Catalyst::Test (Dan Dascalescu) + - Bump to MooseX::MethodAttributes 0.08, to gain the + get_nearest_methods_with_attributes method allowing methods without + attributes in a subclass to override those with attributes in a superclass. + This fixes CatalystX::CRUD's method of overriding/disabling functionality + base controllers (t0m). 5.80002 2009-04-22 01:28:36 - Fix CATALYST_DEBUG and MYAPP_DEBUG environment variables diff --git a/Makefile.PL b/Makefile.PL index b564d98..953aff3 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -9,7 +9,7 @@ requires 'namespace::clean'; requires 'Scope::Upper' => '0.06'; requires 'MooseX::Emulate::Class::Accessor::Fast' => '0.00801'; requires 'Moose' => '0.73'; -requires 'MooseX::MethodAttributes::Inheritable' => '0.06'; +requires 'MooseX::MethodAttributes::Inheritable' => '0.08'; requires 'Carp'; requires 'Class::C3::Adopt::NEXT' => '0.07'; requires 'Class::MOP' => '0.79'; diff --git a/lib/Catalyst/Controller.pm b/lib/Catalyst/Controller.pm index 81be71d..bf082ec 100644 --- a/lib/Catalyst/Controller.pm +++ b/lib/Catalyst/Controller.pm @@ -7,6 +7,7 @@ use namespace::clean -except => 'meta'; BEGIN { extends qw/Catalyst::Component MooseX::MethodAttributes::Inheritable/; } +use MooseX::MethodAttributes; use Catalyst::Exception; use Catalyst::Utils; @@ -179,8 +180,8 @@ sub get_action_methods { my $meta = find_meta($self); confess("Metaclass for " . ref($meta) ." for " . $meta->name . " cannot support register_actions.") - unless $meta->can('get_all_methods_with_attributes'); - my @methods = $meta->get_all_methods_with_attributes; + unless $meta->can('get_nearest_methods_with_attributes'); + my @methods = $meta->get_nearest_methods_with_attributes; return @methods; } diff --git a/t/aggregate/live_component_controller_moose.t b/t/aggregate/live_component_controller_moose.t index 6ed86ba..1f24a16 100644 --- a/t/aggregate/live_component_controller_moose.t +++ b/t/aggregate/live_component_controller_moose.t @@ -4,21 +4,23 @@ use warnings; use FindBin; use lib "$FindBin::Bin/../lib"; -use Test::More tests => 5; +use Test::More tests => 7; use Catalyst::Test 'TestApp'; { my $response = request('http://localhost/moose/get_attribute'); ok($response->is_success); is($response->content, '42', 'attribute default values get set correctly'); + is($response->header('X-Catalyst-Test-Before'), 'before called', 'before works as expected'); } { - my $response = request('http://localhost/moose/methodmodifiers/get_attribute'); - ok($response->is_success); - is($response->content, '42', 'parent controller method called'); TODO: { local $TODO = 'Wrapping methods in a subclass, when the subclass contains no other methods with attributes is broken'; + my $response = request('http://localhost/moose/methodmodifiers/get_attribute'); + ok($response->is_success); + is($response->content, '42', 'parent controller method called'); + is($response->header('X-Catalyst-Test-Before'), 'before called', 'before works as expected'); is($response->header('X-Catalyst-Test-After'), 'after called', 'after works as expected'); } } diff --git a/t/lib/TestApp/Controller/Moose.pm b/t/lib/TestApp/Controller/Moose.pm index d80102e..c03829a 100644 --- a/t/lib/TestApp/Controller/Moose.pm +++ b/t/lib/TestApp/Controller/Moose.pm @@ -5,6 +5,10 @@ use Moose; use namespace::clean -except => 'meta'; BEGIN { extends qw/Catalyst::Controller/; } +use MooseX::MethodAttributes; # FIXME - You need to say this if you have + # modifiers so that you get the correct + # method metaclass, why does the modifier + # on MODIFY_CODE_ATTRIBUTES not work. has attribute => ( is => 'ro', @@ -16,4 +20,9 @@ sub get_attribute : Local { $c->response->body($self->attribute); } +before get_attribute => sub { + my ($self, $c) = @_; + $c->response->header( 'X-Catalyst-Test-Before' => 'before called' ); +}; + 1;