[Bast-commits] r3215 - in trunk/DBIx-Class-TimeStamp: . lib/DBIx/Class t

jshirley at dev.catalyst.perl.org jshirley at dev.catalyst.perl.org
Fri Apr 27 17:21:46 GMT 2007


Author: jshirley
Date: 2007-04-27 17:21:45 +0100 (Fri, 27 Apr 2007)
New Revision: 3215

Added:
   trunk/DBIx-Class-TimeStamp/t/08noclobber.t
Modified:
   trunk/DBIx-Class-TimeStamp/Changes
   trunk/DBIx-Class-TimeStamp/lib/DBIx/Class/TimeStamp.pm
Log:
0.04, LTJake's no-clobber changes + test case

Modified: trunk/DBIx-Class-TimeStamp/Changes
===================================================================
--- trunk/DBIx-Class-TimeStamp/Changes	2007-04-26 17:58:16 UTC (rev 3214)
+++ trunk/DBIx-Class-TimeStamp/Changes	2007-04-27 16:21:45 UTC (rev 3215)
@@ -1,5 +1,8 @@
 Revision history for DBIx::Class::TimeStamp
 
+0.04 2007-04-27 08:41:00
+    - Incorporating LTJake's patch to not clobber set values, LTJake++
+
 0.03 2007-04-03 19:09:00
     - Making the data_type check to be case insensitive, fixing Ticket 26081
 

Modified: trunk/DBIx-Class-TimeStamp/lib/DBIx/Class/TimeStamp.pm
===================================================================
--- trunk/DBIx-Class-TimeStamp/lib/DBIx/Class/TimeStamp.pm	2007-04-26 17:58:16 UTC (rev 3214)
+++ trunk/DBIx-Class-TimeStamp/lib/DBIx/Class/TimeStamp.pm	2007-04-27 16:21:45 UTC (rev 3215)
@@ -7,7 +7,7 @@
 
 use DateTime;
 
-our $VERSION = '0.03';
+our $VERSION = '0.04';
 
 __PACKAGE__->load_components( qw/InflateColumn::DateTime/ );
 __PACKAGE__->mk_classdata( 
@@ -126,6 +126,10 @@
 
 J. Shirley <jshirley at gmail.com>
 
+=head1 CONTRIBUTORS
+
+LTJake
+
 =head1 LICENSE
 
 You may distribute this code under the same terms as Perl itself.

Added: trunk/DBIx-Class-TimeStamp/t/08noclobber.t
===================================================================
--- trunk/DBIx-Class-TimeStamp/t/08noclobber.t	                        (rev 0)
+++ trunk/DBIx-Class-TimeStamp/t/08noclobber.t	2007-04-27 16:21:45 UTC (rev 3215)
@@ -0,0 +1,50 @@
+use strict;
+use warnings;
+
+use Test::More tests => 9;
+
+use DateTime;
+use Time::HiRes;
+use Time::Warp qw|to time|;
+
+# Redefine "now" so that we can warp it.  
+no warnings 'redefine';
+local *DateTime::now = sub { shift->from_epoch( epoch => (scalar time), @_ ) };
+use warnings 'redefine';
+
+use lib qw(t/lib);
+use DBIC::Test;
+
+my $schema = DBIC::Test->init_schema;
+my $row;
+
+my $last_week = DateTime->now() - DateTime::Duration->new( weeks => 1 );
+
+$row = $schema->resultset('DBIC::Test::Schema::TestDatetime')
+    ->create({ display_name => 'test record', t_created => $last_week });
+
+my $time = $row->t_updated;
+
+ok $row->t_created, 'created timestamp';
+ok $row->t_updated, 'updated timestamp';
+is   $row->t_created, $last_week, 'create timestamp';
+isnt $row->t_updated, $row->t_created, 'update and create timestamp';
+
+to(time + 60);
+
+$row->update({ display_name => 'updating test record' });
+
+is $row->display_name, 'updating test record', 'update record';
+isnt $row->t_updated, $time, 'timestamp update';
+$time = $row->t_updated;
+
+to(time + 60);
+
+$row->update({
+    display_name => 'updating test record again', t_updated => $last_week
+});
+
+is $row->display_name, 'updating test record again', 'update record';
+isnt $row->t_updated, $time, 'timestamp update';
+is $row->t_updated, $row->t_created, 'timestamp update is create now';
+




More information about the Bast-commits mailing list