[Bps-public-commit] r14432 - in sd/trunk: lib/App/SD lib/App/SD/CLI/Command/Ticket t

cwest at bestpractical.com cwest at bestpractical.com
Wed Jul 23 12:49:34 EDT 2008


Author: cwest
Date: Wed Jul 23 12:49:33 2008
New Revision: 14432

Modified:
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm
   sd/trunk/lib/App/SD/Model/Ticket.pm
   sd/trunk/lib/App/SD/Record.pm
   sd/trunk/t/00-create.t
   sd/trunk/t/sd-attachments.t
   sd/trunk/t/sd-comments.t

Log:
D8314F5C-58D1-11DD-A02B-20F23D9AEBE7: convert prop(date) to prop(created), provide passive data migration

Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm	Wed Jul 23 12:49:33 2008
@@ -14,7 +14,7 @@
 
     for my $entry (sort { $a->prop('date') cmp $b->prop('date') } @{$record->comments}) {
          print "id: ".$entry->luid." (".$entry->uuid.")\n";
-        print "date: ".$entry->prop('date')."\n";
+        print "created: ".$entry->prop('created')."\n";
         print $entry->prop('content')."\n";
     }
 

Modified: sd/trunk/lib/App/SD/Model/Ticket.pm
==============================================================================
--- sd/trunk/lib/App/SD/Model/Ticket.pm	(original)
+++ sd/trunk/lib/App/SD/Model/Ticket.pm	Wed Jul 23 12:49:33 2008
@@ -46,7 +46,7 @@
 }
 
 sub props_to_show {
-    ('id', 'summary', 'status', 'owner', 'date', 'due', 'creator', 'reported_by', 'CF-Broken in', 'CF-Severity')
+    ('id', 'summary', 'status', 'owner', 'created', 'due', 'creator', 'reported_by', 'CF-Broken in', 'CF-Severity')
 }
 
 # this expects ISO dates. we should improve it in the future to require

Modified: sd/trunk/lib/App/SD/Record.pm
==============================================================================
--- sd/trunk/lib/App/SD/Record.pm	(original)
+++ sd/trunk/lib/App/SD/Record.pm	Wed Jul 23 12:49:33 2008
@@ -7,17 +7,32 @@
 use DateTime;
 
 
-sub declared_props { 'date', inner() }
+sub declared_props { 'created', inner() }
 
 extends 'Prophet::Record';
 
-sub canonicalize_prop_date {
+sub get_props {
+    my $self = shift;
+    my $props = $self->SUPER::get_props(@_);
+
+    $self->set_props(props => { created => $props->{date} })
+      if !$props->{created} && $props->{date};
+
+    $self->set_props(props => {date => undef})
+      if $props->{date};
+
+    return $self->SUPER::get_props(@_);
+}
+
+sub canonicalize_prop_created {
     my $self = shift;
     my %args = validate(@_, { props => 1, errors => 1});
     my $props = shift;
-    if (!$args{props}->{date} ) {
+    my $created =    $args{props}->{created}
+                  || $args{props}->{date};
+    if (!$created ) {
         my $date = DateTime->now;
-        $args{props}->{date} = $date->ymd." ".$date->hms;
+        $args{props}->{created} = $date->ymd." ".$date->hms;
     }
     return 1;
 }

Modified: sd/trunk/t/00-create.t
==============================================================================
--- sd/trunk/t/00-create.t	(original)
+++ sd/trunk/t/00-create.t	Wed Jul 23 12:49:33 2008
@@ -30,7 +30,7 @@
         qr/id:\s+$yatta_id\s+\($yatta_uuid\)/,
         qr/summary:\s+YATTA/,
         qr/status:.+new/,
-        qr/date:\s+\d{4}-\d{2}-\d{2}.+/,
+        qr/created:\s+\d{4}-\d{2}-\d{2}.+/,
     ]
 );
 

Modified: sd/trunk/t/sd-attachments.t
==============================================================================
--- sd/trunk/t/sd-attachments.t	(original)
+++ sd/trunk/t/sd-attachments.t	Wed Jul 23 12:49:33 2008
@@ -31,8 +31,8 @@
     [ 
     
         qr/id: $attachment_id \($attachment_uuid\)/, 
+        qr/created:\s+\d{4}-\d{2}-\d{2}.+/,
         "content_type: text/plain",
-        qr/date:\s+\d{4}-\d{2}-\d{2}.+/,
         qr/paper_order.doc/,
         "content: stub",
         "ticket: $yatta_uuid"
@@ -55,8 +55,8 @@
     [ qw/ticket attachment show --batch --uuid/, $attachment_uuid ],
     [  
         qr/id: (\d+) \($attachment_uuid\)/, 
+        qr/created:\s+\d{4}-\d{2}-\d{2}.+/,
         "content_type: text/plain",
-        qr/date:\s+\d{4}-\d{2}-\d{2}.+/,
         qr/plague_recipe.doc/,
         "content: stub",
         "ticket: $yatta_uuid"

Modified: sd/trunk/t/sd-comments.t
==============================================================================
--- sd/trunk/t/sd-comments.t	(original)
+++ sd/trunk/t/sd-comments.t	Wed Jul 23 12:49:33 2008
@@ -26,7 +26,7 @@
 run_output_matches(
     'sd',
     [ qw/ticket comments --uuid/, $yatta_uuid ],
-    [ qr/^id: \d+ \($comment_uuid\)/, qr/^date: /, "'This is a test'" ],
+    [ qr/^id: \d+ \($comment_uuid\)/, qr/^created: /, "'This is a test'" ],
     [], "Found the comment"
 );
 
@@ -34,7 +34,7 @@
     'sd',
     [ qw/ticket comment show --batch --uuid/, $comment_uuid ],
     [   qr/id: (\d+) \($comment_uuid\)/,
-        qr/date: /i,
+        qr/created: /i,
         qr/This is a test/,
         "ticket: $yatta_uuid"
     ],
@@ -55,7 +55,7 @@
     'sd',
     [ qw/ticket comment show --batch --uuid/, $comment_uuid ],
     [ qr/id: (\d+) \($comment_uuid\)/, 
-        qr/date: /i,
+        qr/created: /i,
     qr/I hate you/, "ticket: $yatta_uuid" ],
     [],
     "Found the comment new version"



More information about the Bps-public-commit mailing list