Version 2.002002
[catagits/Catalyst-Controller-DBIC-API.git] / t / rest / delete.t
CommitLineData
d2739840 1use 5.6.0;
2
3use strict;
4use warnings;
5
6use lib 't/lib';
7
8my $base = 'http://localhost';
9my $content_type = [ 'Content-Type', 'application/x-www-form-urlencoded' ];
10
11use RestTest;
12use DBICTest;
13use Test::More tests => 4;
14use Test::WWW::Mechanize::Catalyst 'RestTest';
15use HTTP::Request::Common;
16
17my $mech = Test::WWW::Mechanize::Catalyst->new;
18ok(my $schema = DBICTest->init_schema(), 'got schema');
19
20my $track = $schema->resultset('Track')->first;
21my %original_cols = $track->get_columns;
22
23my $track_delete_url = "$base/api/rest/track/" . $track->id;
24
25{
26 my $req = HTTP::Request->new( DELETE => $track_delete_url );
27 $req->content_type('text/x-json');
28 $mech->request($req);
29 cmp_ok( $mech->status, '==', 200, 'Attempt to delete track ok' );
30
31 my $deleted_track = $schema->resultset('Track')->find($track->id);
32 is($deleted_track, undef, 'track deleted');
33}
34
35{
36 my $req = HTTP::Request->new( DELETE => $track_delete_url );
37 $req->content_type('text/x-json');
38 $mech->request($req);
39 cmp_ok( $mech->status, '==', 400, 'Attempt to delete again caught' );
40}