From: Hans Dieter Pearcey Date: Sat, 28 Mar 2009 15:46:52 +0000 (-0400) Subject: partial revert of e540a1fa72e4a5425c59a9397a3353f4784d726a -- fixes RT#44641 (plus... X-Git-Tag: 1.08~215 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Action-Serialize-Data-Serializer.git;a=commitdiff_plain;h=0ba737212e82994202544ac6fb61f6d0ffb96184 partial revert of e540a1fa72e4a5425c59a9397a3353f4784d726a -- fixes RT#44641 (plus tests) --- diff --git a/lib/Catalyst/Controller/REST.pm b/lib/Catalyst/Controller/REST.pm index cbe444a..54efe6a 100644 --- a/lib/Catalyst/Controller/REST.pm +++ b/lib/Catalyst/Controller/REST.pm @@ -217,7 +217,6 @@ use Params::Validate qw(SCALAR OBJECT); __PACKAGE__->mk_accessors(qw(serialize)); __PACKAGE__->config( - 'default_view' => 'REST', 'stash_key' => 'rest', 'map' => { 'text/html' => 'YAML::HTML', @@ -237,6 +236,8 @@ __PACKAGE__->config( sub begin : ActionClass('Deserialize') { } +sub end : ActionClass('Serialize') { } + =item status_ok Returns a "200 OK" response. Takes an "entity" to serialize. diff --git a/t/catalyst-controller-rest.t b/t/catalyst-controller-rest.t new file mode 100644 index 0000000..0d1d4eb --- /dev/null +++ b/t/catalyst-controller-rest.t @@ -0,0 +1,21 @@ +use strict; +use warnings; +use Test::More tests => 2; +use YAML::Syck; +use FindBin; + +use lib ("$FindBin::Bin/lib", "$FindBin::Bin/../lib", "$FindBin::Bin/broken"); +use Test::Rest; + +my $t = Test::Rest->new(content_type => 'text/x-yaml'); + +use_ok 'Catalyst::Test', 'Test::Catalyst::Action::REST'; + +my $data = { your => 'face' }; +is_deeply( + Load( + request($t->put(url => '/rest/test', data => Dump($data)))->content + ), + { test => 'worked', data => $data }, + 'round trip (deserialize/serialize)', +); diff --git a/t/lib/Test/Catalyst/Action/REST/Controller/REST.pm b/t/lib/Test/Catalyst/Action/REST/Controller/REST.pm new file mode 100644 index 0000000..9d75b4d --- /dev/null +++ b/t/lib/Test/Catalyst/Action/REST/Controller/REST.pm @@ -0,0 +1,13 @@ +package Test::Catalyst::Action::REST::Controller::REST; + +use strict; +use warnings; + +use base 'Catalyst::Controller::REST'; + +sub test : Local { + my ($self, $c) = @_; + $self->status_ok($c, entity => { test => 'worked', data => $c->req->data }); +} + +1;