The fake example is now broken as we're not smashing random methods. Fix method gener...
t0m [Mon, 25 May 2009 01:21:33 +0000 (02:21 +0100)]
lib/CatalystX/ModelToControllerReflector.pm
t/05_dynamiccontrollers.t
t/10_app.t
t/lib/DynamicAppDemo/Controller/FakeExample.pm [deleted file]

index e7510ff..97c2b9a 100644 (file)
@@ -8,7 +8,7 @@ my $mangle_attributes_on_generated_methods = sub {
     my ($meta, $config) = @_;
     foreach my $name (keys %{ $config->{methods}}) {
         my $m = $meta->get_method($name);
-        $m->meta->get_attribute('attributes')->set_value($m, ['Local']);
+        $meta->register_method_attributes($m->body, ['Local']);
     }
 };
 
index 2f54467..af8a1db 100644 (file)
@@ -6,7 +6,7 @@ use lib "$Bin/lib";
 
 use Moose::Util qw/does_role/;
 
-use Test::More tests => 5;
+use Test::More tests => 6;
 
 use DynamicAppDemo;
 
@@ -23,3 +23,6 @@ ok ! $controller->action_for('get_reflected_action_methods'),
 ok ! $controller->action_for('method_from_controller_role'),
     'not leaking actions';
 
+ok  $controller->action_for('say_hello'),
+    'Am finding generated actions';
+
index 21e1224..b7259cc 100644 (file)
@@ -4,17 +4,11 @@ use warnings;
 use FindBin qw/$Bin/;
 use lib "$Bin/lib";
 
-use Test::More tests => 6;
+use Test::More tests => 4;
 
 BEGIN { use_ok 'Catalyst::Test', 'DynamicAppDemo' }
 
 {
-    my $res = request('/fakeexample/register_me');
-    ok( $res->is_success, 'should succeed' );
-    is( $res->header('X-Foo'), 'bar', 'is calling correct code' );
-}
-
-{
     my $res = request('/one/say_hello/world');
     ok( $res->is_success, 'should succeed' );
     is( $res->header('X-From-Model'), 'One' );
diff --git a/t/lib/DynamicAppDemo/Controller/FakeExample.pm b/t/lib/DynamicAppDemo/Controller/FakeExample.pm
deleted file mode 100644 (file)
index 4615cf4..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-package DynamicAppDemo::Controller::FakeExample;
-use Moose;
-use namespace::autoclean;
-
-BEGIN { extends 'Catalyst::Controller' }
-with 'CatalystX::ModelToControllerReflector::ControllerRole';
-
-# This is a fake controller.
-
-# It exists to show an example of using ::ControllerBase which is autogenerated,
-# which helps me seperate the building and testing of the controller action
-# registration functionality, seperate the the code generation :)
-
-sub register_me { 
-    my ($self, $c) = @_;
-    $c->res->body('quux');
-    $c->res->header('X-Foo', 'bar');
-}
-
-sub _do_not_register_me { }
-
-# In a non-trivial example, you would use MX::Method::Sigs :)
-
-__PACKAGE__->meta->make_immutable;
-