[Bps-public-commit] r14427 - in sd/trunk: lib/App/SD t

cwest at bestpractical.com cwest at bestpractical.com
Wed Jul 23 04:28:24 EDT 2008


Author: cwest
Date: Wed Jul 23 04:28:24 2008
New Revision: 14427

Modified:
   sd/trunk/lib/App/SD/Model/Attachment.pm
   sd/trunk/lib/App/SD/Model/Comment.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

Log:
38F74B4E-5890-11DD-B29A-74F03D9AEBE7: prop(date) for all App::SD::Record types

Modified: sd/trunk/lib/App/SD/Model/Attachment.pm
==============================================================================
--- sd/trunk/lib/App/SD/Model/Attachment.pm	(original)
+++ sd/trunk/lib/App/SD/Model/Attachment.pm	Wed Jul 23 04:28:24 2008
@@ -2,7 +2,8 @@
 use strict;
 
 package App::SD::Model::Attachment;
-use base qw/App::SD::Record/;
+use Moose;
+extends 'App::SD::Record';
 use Params::Validate qw/validate/;
 
 use constant collection_class => 'App::SD::Collection::Attachment';

Modified: sd/trunk/lib/App/SD/Model/Comment.pm
==============================================================================
--- sd/trunk/lib/App/SD/Model/Comment.pm	(original)
+++ sd/trunk/lib/App/SD/Model/Comment.pm	Wed Jul 23 04:28:24 2008
@@ -2,9 +2,8 @@
 use strict;
 
 package App::SD::Model::Comment;
-use base qw/App::SD::Record/;
-use Params::Validate;
-use DateTime;
+use Moose;
+extends 'App::SD::Record';
 
 use constant collection_class => 'App::SD::Collection::Comment';
 use constant type => 'comment';
@@ -12,24 +11,11 @@
 
 sub _default_summary_format { '%s,$uuid | %s,content'}
 
-use constant declared_props => qw(date content);
+augment declared_props => sub {'content'};
 
 
 #has SVK::Model::Ticket;
 
 __PACKAGE__->register_reference( ticket => 'App::SD::Model::Comment');
 
-sub canonicalize_prop_date {
-    my $self = shift;
-    my %args = validate(@_, { props => 1, errors => 1});
-    my $props = shift;
-    if (!$args{props}->{date} ) {
-        my $date = DateTime->now;
-        $args{props}->{date} = $date->ymd." ".$date->hms;
-    }
-    return 1;
-    
-}
-
-
 1;

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 04:28:24 2008
@@ -46,7 +46,7 @@
 }
 
 sub props_to_show {
-    ('id', 'summary', 'status', 'owner', 'due', 'creator', 'reported_by', 'CF-Broken in', 'CF-Severity')
+    ('id', 'summary', 'status', 'owner', 'date', '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 04:28:24 2008
@@ -2,7 +2,26 @@
 use strict;
 
 package App::SD::Record; # should probably be Prophet::App::Record
-use base qw/Prophet::Record/;
+use Moose;
+use Params::Validate;
+use DateTime;
+
+
+sub declared_props { 'date', inner() }
+
+extends 'Prophet::Record';
+
+sub canonicalize_prop_date {
+    my $self = shift;
+    my %args = validate(@_, { props => 1, errors => 1});
+    my $props = shift;
+    if (!$args{props}->{date} ) {
+        my $date = DateTime->now;
+        $args{props}->{date} = $date->ymd." ".$date->hms;
+    }
+    return 1;
+}
+
 
 
 1;

Modified: sd/trunk/t/00-create.t
==============================================================================
--- sd/trunk/t/00-create.t	(original)
+++ sd/trunk/t/00-create.t	Wed Jul 23 04:28:24 2008
@@ -2,7 +2,7 @@
 
 use strict;
 
-use Prophet::Test tests => 2;
+use Prophet::Test tests => 3;
 use App::SD::Test;
 use File::Temp qw/tempdir/;
 use Path::Class;
@@ -24,3 +24,13 @@
    
 );
 
+run_output_matches( 'sd', [ 'ticket',  
+    'show', '--id', $yatta_id ],
+    [
+        qr/id:\s+$yatta_id\s+\($yatta_uuid\)/,
+        qr/summary:\s+YATTA/,
+        qr/status:.+new/,
+        qr/date:\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 04:28:24 2008
@@ -32,6 +32,7 @@
     
         qr/id: $attachment_id \($attachment_uuid\)/, 
         "content_type: text/plain",
+        qr/date:\s+\d{4}-\d{2}-\d{2}.+/,
         qr/paper_order.doc/,
         "content: stub",
         "ticket: $yatta_uuid"
@@ -55,6 +56,7 @@
     [  
         qr/id: (\d+) \($attachment_uuid\)/, 
         "content_type: text/plain",
+        qr/date:\s+\d{4}-\d{2}-\d{2}.+/,
         qr/plague_recipe.doc/,
         "content: stub",
         "ticket: $yatta_uuid"



More information about the Bps-public-commit mailing list