From: Alexander Hartmaier Date: Tue, 2 Mar 2010 16:49:31 +0000 (+0100) Subject: new test for item fetching with inflated objects X-Git-Tag: 2.002001~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Controller-DBIC-API.git;a=commitdiff_plain;h=15754afc0361ee73b24da1b37646732bbeb7a69b new test for item fetching with inflated objects require DBIx::Class::TimeStamp 0.12 which is used by Result::Track for datetime inflation --- diff --git a/dist.ini b/dist.ini index 350a4da..34c2a89 100644 --- 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 diff --git a/t/lib/RestTest/Schema/Result/Track.pm b/t/lib/RestTest/Schema/Result/Track.pm index 9adcdbe..670f88d 100644 --- a/t/lib/RestTest/Schema/Result/Track.pm +++ b/t/lib/RestTest/Schema/Result/Track.pm @@ -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' => { diff --git a/t/rest/item.t b/t/rest/item.t index a376a6b..bd1423d 100644 --- a/t/rest/item.t +++ b/t/rest/item.t @@ -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();