[Bast-commits] r8600 -
DBIx-Class/0.08/branches/multi_update/t/multi_update
gshank at dev.catalyst.perl.org
gshank at dev.catalyst.perl.org
Wed Feb 10 16:20:56 GMT 2010
Author: gshank
Date: 2010-02-10 16:20:56 +0000 (Wed, 10 Feb 2010)
New Revision: 8600
Modified:
DBIx-Class/0.08/branches/multi_update/t/multi_update/cd_single.t
DBIx-Class/0.08/branches/multi_update/t/multi_update/has_many.t
Log:
use update_or_create
Modified: DBIx-Class/0.08/branches/multi_update/t/multi_update/cd_single.t
===================================================================
--- DBIx-Class/0.08/branches/multi_update/t/multi_update/cd_single.t 2010-02-10 12:47:22 UTC (rev 8599)
+++ DBIx-Class/0.08/branches/multi_update/t/multi_update/cd_single.t 2010-02-10 16:20:56 UTC (rev 8600)
@@ -9,7 +9,7 @@
my $schema = DBICTest->init_schema();
my $cd = $schema->resultset('CD')->first;
-my $track = {
+my $track_hash = {
cd => $cd,
title => 'Multicreate rocks',
cd_single => {
@@ -19,8 +19,7 @@
},
};
-my $cd = $schema->resultset('CD')->first;
-my $track = $schema->resultset('Track')->new_result($track);
+my $track = $schema->resultset('Track')->new_result($track_hash);
isa_ok( $track, 'DBICTest::Track', 'Main Track object created' );
$track->insert;
@@ -29,9 +28,9 @@
is( $track->title, 'Multicreate rocks', 'Correct Track title' );
is( $track->cd_single->title, 'Disemboweling MultiCreate' );
-delete $track->{cd};
-$track->{cd_single}->{title} = 'Disemboweling MultiUpdate';
-$track->update($track);
+$track_hash->{trackid} = $track->trackid;
+$track_hash->{cd_single}->{title} = 'Disemboweling MultiUpdate';
+$schema->resultset('Track')->update_or_create($track_hash);
is( $track->cd_single->title, 'Disemboweling MultiUpdate', 'correct cd_single title' );
done_testing;
Modified: DBIx-Class/0.08/branches/multi_update/t/multi_update/has_many.t
===================================================================
--- DBIx-Class/0.08/branches/multi_update/t/multi_update/has_many.t 2010-02-10 12:47:22 UTC (rev 8599)
+++ DBIx-Class/0.08/branches/multi_update/t/multi_update/has_many.t 2010-02-10 16:20:56 UTC (rev 8600)
@@ -6,8 +6,6 @@
use lib qw(t/lib);
use DBICTest;
-plan tests => 2;
-
my $schema = DBICTest->init_schema();
my $track_no_lyrics = $schema->resultset ('Track')
@@ -23,7 +21,9 @@
is ($lyric->lyric_versions->count, 2, "Two identical has_many's created");
# should the lyric_versions have pks? just replace them all?
-$track_no_lyrics->update( {
+# this tries to do a create
+$track_no_lyrics = $schema->resultset('Track')->update_or_create( {
+ trackid => $track_no_lyrics->trackid,
title => 'Titled Updated by Multi Update',
lyrics => {
lyric_versions => [
@@ -36,21 +36,4 @@
is( $track_no_lyrics->lyrics->search_related('lyric_versions', { text => 'Other text' } )->count, 1, 'related record updated' );
-my $link = $schema->resultset ('Link')->create ({
- url => 'lolcats!',
- bookmarks => [
- {},
- {},
- ]
-});
-is ($link->bookmarks->count, 2, "Two identical default-insert has_many's created");
-
-# what should happen?
-$link->update( {
- url => 'lolkittens!',
- bookmarks => [
- {}
- ]
-});
-is( $link->url, 'lolkittens!', 'url updated' );
-is( $link->bookmarks->count, 1, 'One default bookmark' );
+done_testing;
More information about the Bast-commits
mailing list