From: Florian Ragwitz Date: Sun, 28 Feb 2010 22:57:08 +0000 (+0100) Subject: Add failing test for updating related rows with ::REST. X-Git-Tag: 2.002001~27 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Controller-DBIC-API.git;a=commitdiff_plain;h=9f9ffe56eb079d043d93776f40ecc2a54f2c142a Add failing test for updating related rows with ::REST. --- diff --git a/t/lib/RestTest/Controller/API/REST/Track.pm b/t/lib/RestTest/Controller/API/REST/Track.pm index 6a7bcf0..f8b15b8 100644 --- a/t/lib/RestTest/Controller/API/REST/Track.pm +++ b/t/lib/RestTest/Controller/API/REST/Track.pm @@ -9,7 +9,7 @@ __PACKAGE__->config class => 'RestTestDB::Track', create_requires => ['cd', 'title' ], create_allows => ['cd', 'title', 'position' ], - update_allows => ['title', 'position'] + update_allows => ['title', 'position', { cd => ['*'] }], ); 1; diff --git a/t/rest/update.t b/t/rest/update.t index ee5837b..ad4c025 100644 --- a/t/rest/update.t +++ b/t/rest/update.t @@ -10,7 +10,7 @@ my $content_type = [ 'Content-Type', 'application/x-www-form-urlencoded' ]; use RestTest; use DBICTest; -use Test::More tests => 15; +use Test::More tests => 16; use Test::WWW::Mechanize::Catalyst 'RestTest'; use HTTP::Request::Common; use JSON::Any; @@ -71,7 +71,7 @@ my $track_update_url = "$base/api/rest/track/" . $track->id; } { - my $test_data = JSON::Any->Dump({ title => 'monkey monkey' }); + my $test_data = JSON::Any->Dump({ title => 'monkey monkey', 'cd.year' => 2009 }); my $req = POST( $track_update_url, Content => $test_data ); $req->content_type('text/x-json'); $mech->request($req); @@ -80,4 +80,5 @@ my $track_update_url = "$base/api/rest/track/" . $track->id; $track->discard_changes; is($track->title, 'monkey monkey', 'Title changed to "monkey monkey"'); + is($track->cd->year, 2009, 'related row updated'); } diff --git a/t/var/DBIxClass.db b/t/var/DBIxClass.db index a2e3024..7893e77 100644 Binary files a/t/var/DBIxClass.db and b/t/var/DBIxClass.db differ