From: Tomas Doran Date: Mon, 28 Jul 2008 20:39:00 +0000 (+0000) Subject: Commit a failing test for components getting config from self. This is a showstopper... X-Git-Tag: 5.8000_03~83 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=2ef599586739f410da035904753378000a368a44 Commit a failing test for components getting config from self. This is a showstopper regression IMO, so it is not TODO. Change around new to BUILDARGS in C::Component --- diff --git a/Changes b/Changes index 95f397b..8903baa 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,7 @@ 5.8000 - Port to Moose - Added test for action stringify + - Added test for component instances getting $self->{value} from config. 5.7013 - Fix subdirs for scripts that run in subdirs more than one level deep. diff --git a/Makefile.PL b/Makefile.PL index d785b4a..62a7279 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -7,7 +7,7 @@ name 'Catalyst-Runtime'; all_from 'lib/Catalyst/Runtime.pm'; requires 'MooseX::Emulate::Class::Accessor::Fast'; - +requires 'Moose' => '0.51'; requires 'Carp'; requires 'Class::Accessor::Fast'; requires 'Class::Data::Inheritable'; diff --git a/lib/Catalyst/Component.pm b/lib/Catalyst/Component.pm index 68dbcdb..1f1fbb5 100644 --- a/lib/Catalyst/Component.pm +++ b/lib/Catalyst/Component.pm @@ -57,15 +57,16 @@ component loader with config() support and a process() method placeholder. __PACKAGE__->mk_classdata('_plugins'); __PACKAGE__->mk_classdata('_config'); -around new => sub { - my ( $orig, $self) = @_; - +sub BUILDARGS { + my ($self) = @_; + # Temporary fix, some components does not pass context to constructor my $arguments = ( ref( $_[-1] ) eq 'HASH' ) ? $_[-1] : {}; my $args = $self->merge_config_hashes( $self->config, $arguments ); - $self->$orig( $args ); -}; + + return $args; +} no Moose; diff --git a/lib/Catalyst/Model.pm b/lib/Catalyst/Model.pm index 4ab2ebc..f573770 100644 --- a/lib/Catalyst/Model.pm +++ b/lib/Catalyst/Model.pm @@ -5,9 +5,6 @@ extends qw/Catalyst::Component/; no Moose; -#We can't immutablize anything that ISA Component just yet -#__PACKAGE__->meta->make_immutable(); - =head1 NAME Catalyst::Model - Catalyst Model base class diff --git a/t/lib/TestApp/Model/Foo.pm b/t/lib/TestApp/Model/Foo.pm index b0418e8..d4af11c 100644 --- a/t/lib/TestApp/Model/Foo.pm +++ b/t/lib/TestApp/Model/Foo.pm @@ -5,8 +5,12 @@ use warnings; use base qw/ Catalyst::Model /; +__PACKAGE__->config( 'quux' => 'chunkybacon' ); + sub model_foo_method { 1 } +sub model_quux_method { shift->{quux} } + package TestApp::Model::Foo::Bar; sub model_foo_bar_method_from_foo { 1 } diff --git a/t/unit_core_component_layers.t b/t/unit_core_component_layers.t index 4261365..c15bc73 100644 --- a/t/unit_core_component_layers.t +++ b/t/unit_core_component_layers.t @@ -1,4 +1,4 @@ -use Test::More tests => 5; +use Test::More tests => 6; use strict; use warnings; use lib 't/lib'; @@ -19,3 +19,8 @@ my $model_foo_bar = $model_foo->bar; can_ok($model_foo_bar, 'model_foo_bar_method_from_foo'); can_ok($model_foo_bar, 'model_foo_bar_method_from_foo_bar'); + +TestApp->setup; + +is($model_foo->model_quux_method, 'chunkybacon', 'Model method getting $self->{quux} from config'); +