Can you explain what motivated the change?
On Mar 18, 2008, at 2:39 PM, Jifty commits wrote:
Author: dpavlin Date: Tue Mar 18 14:39:52 2008 New Revision: 5229 Added: jifty/trunk/t/TestApp/t/22-canonicalize-load_or_create.t Modified: jifty/trunk/lib/Jifty/Record.pm Log: run canonicalization before load in load_or_create Modified: jifty/trunk/lib/Jifty/Record.pm= = = = = = = = ======================================================================--- jifty/trunk/lib/Jifty/Record.pm (original) +++ jifty/trunk/lib/Jifty/Record.pm Tue Mar 18 14:39:52 2008 @@ -143,6 +143,13 @@ my %args = (@_); + foreach my $key ( keys %args ) { + $args{$key} = $self->run_canonicalization_for_column( + column => $key, + value => $args{$key} + ); + } + my ( $id, $msg ) = $self->load_by_cols(%args); unless ( $self->id ) { return $self->create(%args); Added: jifty/trunk/t/TestApp/t/22-canonicalize-load_or_create.t= = = = = = = = ======================================================================--- (empty file)+++ jifty/trunk/t/TestApp/t/22-canonicalize-load_or_create.t Tue Mar 18 14:39:52 2008@@ -0,0 +1,38 @@ +#!/usr/bin/env perl +use warnings; +use strict; + +=head1 DESCRIPTION + +Test canonicalize on load_or_create + +=cut + +use lib 't/lib'; +use Jifty::SubTest; + +use Jifty::Test tests => 9; +use_ok('TestApp::Model::CanonTest'); + +# Grab a system use +my $system_user = TestApp::CurrentUser->superuser; +ok($system_user, "Found a system user"); + +# Try testing a create +my $o = TestApp::Model::CanonTest->new(current_user => $system_user); +my ($id) = $o->create( column_1 => 'foo#$bar' ); +ok($id, "CanonTest create returned success"); +ok($o->id, "New CanonTest has valid id set"); +is($o->id, $id, "Create returned the right id"); +is($o->column_1, 'foobar', "Created object has the right column_1"); + +# And another +$o->load_or_create( column_1 => 'foo()bar' ); +ok($o->id, "CanonTest create returned value"); +is($o->id, $id, "And it is same from the previous one"); + +# Searches in general+my $collection = TestApp::Model::CanonTestCollection- >new(current_user => $system_user);+$collection->unlimit; +is($collection->count, 1, "Finds one records"); + _______________________________________________ Jifty-commit mailing list [EMAIL PROTECTED] http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-commit
PGP.sig
Description: This is a digitally signed message part
_______________________________________________ jifty-devel mailing list [email protected] http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
