new test for item fetching with inflated objects
Alexander Hartmaier [Tue, 2 Mar 2010 16:49:31 +0000 (17:49 +0100)]
require DBIx::Class::TimeStamp 0.12 which is used by Result::Track for datetime inflation

dist.ini
t/lib/RestTest/Schema/Result/Track.pm
t/rest/item.t

index 350a4da..34c2a89 100644 (file)
--- a/dist.ini
+++ b/dist.ini
@@ -19,6 +19,7 @@ repository                          = git://git.shadowcat.co.uk/catagits/Catalys
 
 [Prereq]
 DBIx::Class = 0.08103
+DBIx::Class::TimeStamp = 0.12
 Catalyst::Runtime = 5.7010
 Catalyst::Controller::ActionRole = 0
 Catalyst::ActionRole::MatchRequestMethod = 0
index 9adcdbe..670f88d 100644 (file)
@@ -1,7 +1,9 @@
 package # hide from PAUSE
     RestTest::Schema::Result::Track;
 
-use base 'DBIx::Class::Core';
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components(qw/ TimeStamp Core /);
 __PACKAGE__->table('track');
 __PACKAGE__->add_columns(
   'trackid' => {
index a376a6b..bd1423d 100644 (file)
@@ -40,4 +40,19 @@ my $artist_view_url = "$base/api/rest/artist/";
     like($response->{messages}->[0], qr/^No object found for id/, 'error message for not existing object fetch ok');
 }
 
+my $track_view_url = "$base/api/rest/track/";
+
+{
+    my $id = 9;
+    my $req = GET( $track_view_url . $id, undef, 'Accept' => 'application/json' );
+    $mech->request($req);
+    cmp_ok( $mech->status, '==', 200, 'got track with datetime object okay' );
+    my %expected_response = $schema->resultset('Track')->find($id)->get_columns;
+    warn $mech->content, "\n";
+    my $response = JSON::Any->Load( $mech->content);
+    use Data::Dumper;
+    warn Dumper($response);
+    is_deeply( $response, { data => \%expected_response, success => 'true' }, 'correct data returned for track with datetime' );
+}
+
 done_testing();