[Bps-public-commit] SD branch, master, updated. 65a2364e0b9467094d9f244eac7780a0f5c30d13

jesse jesse at bestpractical.com
Thu Jun 11 11:50:54 EDT 2009


The branch, master has been updated
       via  65a2364e0b9467094d9f244eac7780a0f5c30d13 (commit)
       via  cdcfeed21b4c4cbab735ed2dfa7d5dfe3257d242 (commit)
      from  673beb87b9fdc8f3dd1c7fa18760ddf219031913 (commit)

Summary of changes:
 lib/App/SD/CLI/Command/Ticket/Show.pm |   68 +++++++++++++++++++++++++--------
 t/06-ticket-show.t                    |   20 +++++-----
 t/sd-comments.t                       |    2 +-
 3 files changed, 63 insertions(+), 27 deletions(-)

- Log -----------------------------------------------------------------
commit cdcfeed21b4c4cbab735ed2dfa7d5dfe3257d242
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Jun 11 11:24:17 2009 -0400

    Slightly de-brittle our ticket show tests

diff --git a/t/06-ticket-show.t b/t/06-ticket-show.t
index 80000b8..fa3802d 100644
--- a/t/06-ticket-show.t
+++ b/t/06-ticket-show.t
@@ -34,11 +34,11 @@ TODO: {
             '',
             '= METADATA',
             '',
-            "id:               $ticket_id ($ticket_uuid)",
-            'summary:          YATTA',
-            'status:           ' .'new',
-            'milestone:        alpha',
-            'component:        core',
+            qr/^id:\s+$ticket_id \($ticket_uuid\)$/,
+            qr/summary:\s+YATTA/,
+            qr/status:\s+new/,
+            qr/milestone:\s+alpha/,
+            qr/component:\s+core/,
             qr/^created:\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/,
             qr/^creator:\s+$ENV{PROPHET_EMAIL}$/,
             qr/reporter:\s+$ENV{PROPHET_EMAIL}$/,
@@ -71,11 +71,11 @@ sub check_output_without_history {
             '',
             '= METADATA',
             '',
-            "id:               $ticket_id ($ticket_uuid)",
-            'summary:          YATTA',
-            'status:           ' .'new', 
-            'milestone:        alpha',
-            'component:        core',
+            qr/^id:\s+$ticket_id \($ticket_uuid\)$/,
+            qr'summary:\s+YATTA',
+            qr'status:\s+new', 
+            qr'milestone:\s+alpha',
+            qr'component:\s+core',
             qr/^created:\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/,
             qr/^creator:\s+$ENV{PROPHET_EMAIL}$/,
             qr/reporter:\s+$ENV{PROPHET_EMAIL}$/,
diff --git a/t/sd-comments.t b/t/sd-comments.t
index 6693bb6..22b267e 100644
--- a/t/sd-comments.t
+++ b/t/sd-comments.t
@@ -79,7 +79,7 @@ run_output_matches(
     [ qw/ticket comment list --uuid/, $yatta_uuid ],
     [qr/$comment_uuid/],
     [],
-    "Found the comment when we tried to search for all comments on a ticket by the ticket's uuid"
+    "Found the comment $comment_uuid when we tried to search for all comments on a ticket by the ticket's uuid, $yatta_uuid"
 );
 
 run_output_matches(

commit 65a2364e0b9467094d9f244eac7780a0f5c30d13
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Jun 11 11:50:35 2009 -0400

    Refactoring show to start to let us customize the display format

diff --git a/lib/App/SD/CLI/Command/Ticket/Show.pm b/lib/App/SD/CLI/Command/Ticket/Show.pm
index 98c2e7d..f94a8b9 100644
--- a/lib/App/SD/CLI/Command/Ticket/Show.pm
+++ b/lib/App/SD/CLI/Command/Ticket/Show.pm
@@ -4,8 +4,13 @@ extends 'Prophet::CLI::Command::Show';
 with 'App::SD::CLI::Command';
 with 'App::SD::CLI::Model::Ticket';
 
-sub ARG_TRANSLATIONS { shift->SUPER::ARG_TRANSLATIONS(),  a => 'all-props', s => 'skip-history',
-                                        h => 'with-history', b => 'batch' };
+sub ARG_TRANSLATIONS {
+    shift->SUPER::ARG_TRANSLATIONS(),
+        a => 'all-props',
+        s => 'skip-history',
+        h => 'with-history',
+        b => 'batch';
+}
 
 sub by_creation_date { $a->prop('created') cmp $b->prop('created') };
 
@@ -28,7 +33,7 @@ override run => sub {
     my @attachments = sort by_creation_date @{$record->attachments};
     if (@attachments) {
         print "\n= ATTACHMENTS\n\n";
-        print $_->format_summary . "\n"
+        $self->show_attachment($_)
             for @attachments;
     }
 
@@ -36,6 +41,50 @@ override run => sub {
     if (@comments) {
         print "\n= COMMENTS\n\n";
         for my $comment (@comments) {
+
+            $self->show_comment($comment);
+
+        }
+    }
+
+    # allow user to not display history by specifying the --skip-history
+    # arg or setting disable_ticket_show_history_by_default config item to a
+    # true value (can be overridden with --with-history)
+    if (!$self->has_arg('skip-history') && (!$self->app_handle->config->get(
+                'disable_ticket_show_history_by_default') ||
+            $self->has_arg('with-history'))) {
+        print "\n= HISTORY\n\n";
+        foreach my $changeset ($record->changesets) {
+            $self->show_history_entry($record, $changeset);
+        }
+    }
+};
+
+sub show_history_entry {
+    my $self = shift;
+    my $ticket = shift;
+    my $changeset = shift;
+    my $out ='';
+        $out .= $changeset->as_string(change_filter => sub {
+            $ticket->uuid eq $self->uuid
+        });
+    print $out;
+}
+
+
+
+
+sub show_attachment {
+    my $self = shift;
+   my $attachment = shift; 
+        print $attachment->format_summary . "\n"
+}
+
+
+sub show_comment {
+    my $self = shift;
+    my $comment = shift;
+
             my $creator = $comment->prop('creator');
             my $created = $comment->prop('created');
             my $content_type = $comment->prop('content_type') ||'text/plain';
@@ -57,19 +106,6 @@ override run => sub {
             print $content;
             print "\n\n";
         }
-    }
-
-    # allow user to not display history by specifying the --skip-history
-    # arg or setting disable_ticket_show_history_by_default config item to a
-    # true value (can be overridden with --with-history)
-    if (!$self->has_arg('skip-history') && (!$self->app_handle->config->get(
-                'disable_ticket_show_history_by_default') ||
-            $self->has_arg('with-history'))) {
-        print "\n= HISTORY\n\n";
-        print $record->history_as_string;
-    }
-};
-
 __PACKAGE__->meta->make_immutable;
 no Any::Moose;
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list