Applied mst fixes for delete on resultsetin [839] to update. Factored out common...
[dbsrgits/DBIx-Class.git] / t / run / 06relationship.tl
index 9d2669e..04d1e36 100644 (file)
@@ -3,7 +3,7 @@ my $schema = shift;
 
 use strict;
 use warnings;  
-plan tests => 21;
+plan tests => 25;
 
 # has_a test
 my $cd = $schema->resultset("CD")->find(4);
@@ -137,6 +137,15 @@ my $trackset = $artist->cds->search_related('tracks');
 # LEFT join means we also see the trackless additional album...
 cmp_ok($trackset->count, '==', 11, "Correct number of tracks for artist");
 
+# now see about updating eveything that belongs to artist 2 to artist 3
+$artist = $schema->resultset("Artist")->find(2);
+my $nartist = $schema->resultset("Artist")->find(3);
+cmp_ok($artist->cds->count, '==', 1, "Correct orig #cds for artist");
+cmp_ok($nartist->cds->count, '==', 1, "Correct orig #cds for artist");
+$artist->cds->update({artist => $nartist->id});
+cmp_ok($artist->cds->count, '==', 0, "Correct new #cds for artist");
+cmp_ok($nartist->cds->count, '==', 2, "Correct new #cds for artist");
+
 }
 
 1;