From: Guillermo Roditi Date: Mon, 21 May 2007 22:29:11 +0000 (+0000) Subject: result_class is getting leaked somewhere in related_resultset, failing test included X-Git-Tag: v0.08010~150^2~59 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6c0ddbf737fa59fd988b0ca3bdbd0e68d2ef9e6d;p=dbsrgits%2FDBIx-Class.git result_class is getting leaked somewhere in related_resultset, failing test included --- diff --git a/Changes b/Changes index d4cc20e..89d9328 100644 --- a/Changes +++ b/Changes @@ -10,6 +10,7 @@ Revision history for DBIx::Class not a foreign constraint is needed - resultset_class/result_class now (again) auto loads the specified class; requires Class::Accessor::Grouped 0.05002+ + - added 97result_class.t test, failing ATM 0.07006 2007-04-17 23:18:00 - Lots of documentation updates diff --git a/t/97result_class.t b/t/97result_class.t new file mode 100644 index 0000000..820948b --- /dev/null +++ b/t/97result_class.t @@ -0,0 +1,38 @@ +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest->init_schema(); + +plan tests => 7; + +{ + my $cd_rc = $schema->resultset("CD")->result_class; + + my $artist_rs = $schema->resultset("Artist") + ->search_rs({}, {result_class => "IWillExplode"}); + is($artist_rs->result_class, 'IWillExplode', 'Correct artist result_class'); + + my $cd_rs = $artist_rs->related_resultset('cds'); + is($cd_rs->result_class, $cd_rc, 'Correct cd result_class'); + + isa_ok(eval {$cd_rs->find(1) }, $cd_rc, 'Inflated into correct cd result_class'); +} + + +{ + my $cd_rc = $schema->resultset("CD")->result_class; + + my $artist_rs = $schema->resultset("Artist") + ->search_rs({}, {result_class => "IWillExplode"})->search({artistis => 1}); + is($artist_rs->result_class, 'IWillExplode', 'Correct artist result_class'); + + my $cd_rs = $artist_rs->related_resultset('cds'); + is($cd_rs->result_class, $cd_rc, 'Correct cd result_class'); + + isa_ok(eval{ $cd_rs->find(1) }, $cd_rc, 'Inflated into correct cd result_class'); + isa_ok(eval { $cd_rs->search({ cdid => 1 })->first}, $cd_rc, 'Inflated into correct cd result_class'); +}