added test for action that returns an error
Alexander Hartmaier [Tue, 22 Mar 2011 09:45:30 +0000 (10:45 +0100)]
t/lib/RestTest/Controller/API/REST/Artist.pm
t/rest/item.t

index 3dad378..d2ceada 100644 (file)
@@ -12,4 +12,10 @@ __PACKAGE__->config
       prefetch_allows => [[qw/ cds /],{ 'cds' => 'tracks'}],
       );
 
+sub action_with_error : Chained('objects_no_id') PathPart('action_with_error') Args(0) {
+    my ( $self, $c ) = @_;
+
+    $c->res->status(404);
+}
+
 1;
index 3b075aa..dbc5e60 100644 (file)
@@ -70,4 +70,17 @@ my $track_view_url = "$base/api/rest/track/";
     );
 }
 
+{
+    my $req =
+        GET( $artist_view_url . 'action_with_error', undef, 'Accept' => 'application/json' );
+    $mech->request($req);
+    cmp_ok( $mech->status, '==', 404, 'action returned error 404' );
+    my $response = $json->decode( $mech->content );
+    is_deeply(
+        $response,
+        { success => 'false' },
+        'correct data returned'
+    );
+}
+
 done_testing();