partial revert of e540a1fa72e4a5425c59a9397a3353f4784d726a -- fixes RT#44641 (plus...
Hans Dieter Pearcey [Sat, 28 Mar 2009 15:46:52 +0000 (11:46 -0400)]
lib/Catalyst/Controller/REST.pm
t/catalyst-controller-rest.t [new file with mode: 0644]
t/lib/Test/Catalyst/Action/REST/Controller/REST.pm [new file with mode: 0644]

index cbe444a..54efe6a 100644 (file)
@@ -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 (file)
index 0000000..0d1d4eb
--- /dev/null
@@ -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 (file)
index 0000000..9d75b4d
--- /dev/null
@@ -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;