From: Florian Ragwitz Date: Thu, 14 Apr 2011 11:50:50 +0000 (+0200) Subject: Add a test for configuring attributes for all actions X-Git-Tag: 5.80033~25 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=7d81af7e1358baaee20d748f36b85791378c30ae;hp=72d5e5c01f94b74edc070d13616ce5112f3b16ad Add a test for configuring attributes for all actions --- diff --git a/t/aggregate/live_component_controller_action_action.t b/t/aggregate/live_component_controller_action_action.t index 8dda203..e74642f 100644 --- a/t/aggregate/live_component_controller_action_action.t +++ b/t/aggregate/live_component_controller_action_action.t @@ -166,6 +166,29 @@ sub run_tests { 'Content is a serialized Catalyst::Request' ); } + + { + ok( my $response = request('http://localhost/action_action_eight'), + 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), + 'action_action_eight', 'Test Action' ); + is( + $response->header('X-Test-Class'), + 'TestApp::Controller::Action::Action', + 'Test Class' + ); + like( + $response->content, + qr/^bless\( .* 'Catalyst::Action' \)$/s, + 'Content is a serialized Catalyst::Action' + ); + + my $action = eval $response->content; + is_deeply $action->attributes->{extra_attribute}, [13]; + is_deeply $action->attributes->{another_extra_attribute}, ['foo']; + } } done_testing; diff --git a/t/lib/TestApp/Controller/Action/Action.pm b/t/lib/TestApp/Controller/Action/Action.pm index 21d4f51..6cee5f5 100644 --- a/t/lib/TestApp/Controller/Action/Action.pm +++ b/t/lib/TestApp/Controller/Action/Action.pm @@ -5,7 +5,9 @@ use base 'TestApp::Controller::Action'; __PACKAGE__->config( actions => { - action_action_five => { ActionClass => '+Catalyst::Action::TestBefore' }, + '*' => { extra_attribute => 13 }, + action_action_five => { ActionClass => '+Catalyst::Action::TestBefore' }, + action_action_eight => { another_extra_attribute => 'foo' }, }, action_args => { '*' => { extra_arg => 42 }, @@ -51,4 +53,9 @@ sub action_action_seven : Global : ActionClass('~TestExtraArgsAction') { $c->forward('TestApp::View::Dump::Request'); } +sub action_action_eight : Global { + my ( $self, $c ) = @_; + $c->forward('TestApp::View::Dump::Action'); +} + 1;