[Bps-public-commit] SD branch, master, updated. 0.70-20-ge69f08d

jesse jesse at bestpractical.com
Tue Sep 1 18:41:05 EDT 2009


The branch, master has been updated
       via  e69f08d6d1b653390e9d7cd1947bb9a9cb6fedca (commit)
      from  696f19491e5a557b39d98e1d773f53716914d8ec (commit)

Summary of changes:
 lib/App/SD/Replica/trac/PushEncoder.pm             |   13 +++----------
 ...w-ticket-to-trac-then-pull.t => push-comment.t} |   17 +++++++++++------
 2 files changed, 14 insertions(+), 16 deletions(-)
 copy t/sd-trac/{push-new-ticket-to-trac-then-pull.t => push-comment.t} (87%)

- Log -----------------------------------------------------------------
commit e69f08d6d1b653390e9d7cd1947bb9a9cb6fedca
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Tue Sep 1 18:26:59 2009 -0400

    Fix push of comments to trac
    
    closes d2681106-3365-51b8-8b15-2e85e8b7ffd3

diff --git a/lib/App/SD/Replica/trac/PushEncoder.pm b/lib/App/SD/Replica/trac/PushEncoder.pm
index 2e2cf13..15a9f58 100644
--- a/lib/App/SD/Replica/trac/PushEncoder.pm
+++ b/lib/App/SD/Replica/trac/PushEncoder.pm
@@ -55,16 +55,9 @@ sub integrate_comment {
     my %props = map { $_->name => $_->new_value } $change->prop_changes;
 
     my $ticket_id     = $self->sync_source->remote_id_for_uuid( $props{'ticket'} );
-    my $ticket = Net::Trac::Ticket->new( trac => $self->sync_source->trac, id => $ticket_id);
-
-    my %content = ( message => $props{'content'},   
-                );
-
-    if (  ($props{'type'} ||'') eq 'comment' ) {
-        $ticket->comment( %content);
-    } else {
-        $ticket->correspond(%content);
-    }
+    my $ticket = Net::Trac::Ticket->new( connection => $self->sync_source->trac);
+    $ticket->load($ticket_id);
+    $ticket->comment( $props{content});
     return $ticket_id;
 } 
 
diff --git a/t/sd-trac/push-comment.t b/t/sd-trac/push-comment.t
new file mode 100644
index 0000000..5c894a5
--- /dev/null
+++ b/t/sd-trac/push-comment.t
@@ -0,0 +1,112 @@
+use warnings;
+use strict;
+
+use Prophet::Test;
+use App::SD::Test;
+
+BEGIN {
+    require File::Temp;
+    $ENV{'PROPHET_REPO'} = $ENV{'SD_REPO'} = File::Temp::tempdir( CLEANUP => 1 ) . '/_svb';
+    diag "export SD_REPO=" . $ENV{'PROPHET_REPO'} . "\n";
+}
+
+unless (`which trac-admin`) { plan skip_all => 'You need trac installed to run the tests'; }
+unless ( eval { require Net::Trac } ) {
+    plan skip_all => 'You need Net::Trac installed to run the tests';
+}
+plan tests => 17;
+
+use_ok('Net::Trac::Connection');
+use_ok('Net::Trac::Ticket');
+require 't/sd-trac/setup_trac.pl';
+
+my $tr = Net::Trac::TestHarness->new();
+ok( $tr->start_test_server(), "The server started!" );
+
+my $trac = Net::Trac::Connection->new(
+    url      => $tr->url,
+    user     => 'hiro',
+    password => 'yatta'
+);
+
+my $sd_trac_url = "trac:" . $tr->url;
+$sd_trac_url =~ s|http://|http://hiro:yatta@|;
+
+isa_ok( $trac, "Net::Trac::Connection" );
+is( $trac->url, $tr->url );
+
+is( count_tickets_in_trac(), 0 );
+
+#
+# Clone from trac
+#
+
+my ( $ret, $out, $err )
+    = run_script( 'sd', [ 'clone', '--from', $sd_trac_url, '--non-interactive' ] );
+is( count_tickets_in_sd(), 0 );
+ok(!($?>>8), $out." ".$err);
+#
+# create a ticket in sd
+#
+my ( $yatta_id, $yatta_uuid ) = create_ticket_ok( '--summary', 'This ticket originated in SD' );
+
+run_output_matches(
+    'sd', [ 'ticket',
+        'list', '--regex', 'This ticket originated in SD' ],
+    [qr/(\d+) This ticket originated in SD new/]
+
+);
+
+run_output_matches(
+    'sd',
+    [ 'ticket', 'basics', '--batch', '--id', $yatta_id ],
+    [   "id: $yatta_id ($yatta_uuid)",
+        'summary: This ticket originated in SD',
+        'status: new',
+        'milestone: alpha',
+        'component: core',
+        qr/^created: \d{4}-\d{2}-\d{2}.+$/,
+        'creator: ' . $ENV{PROPHET_EMAIL},
+        'reporter: ' . $ENV{PROPHET_EMAIL},
+        "original_replica: " . replica_uuid,
+    ]
+);
+
+is( count_tickets_in_sd(),   1 );
+is( count_tickets_in_trac(), 0 );
+
+#
+# push our ticket to trac
+#
+
+($ret,$out,$err) = run_script( 
+    'sd' , ['ticket' ,'comment', $yatta_id, '--content', "The text of the comment."]);
+
+
+ok(!($?>>8), $err);
+
+($ret,$out,$err) = run_script( 'sd', [ 'push', '--to', $sd_trac_url ] );
+ok(!($?>>8), $err);
+diag($out);
+diag($err);
+is( count_tickets_in_trac(), 1 );
+my $tickets = Net::Trac::TicketSearch->new( connection => $trac );
+my $result  = $tickets->query( summary => { not => 'nonsense' } );
+like($tickets->results->[0]->comments->[0]->content, qr/The text of the comment./);
+
+
+
+sub count_tickets_in_sd {
+    my $self = shift;
+    my ( $ret, $out, $err ) = run_script( 'sd' => [ 'ticket', 'list', '--regex', '.' ], );
+    my @lines = split( /\n/, $out );
+    return scalar @lines;
+}
+
+sub count_tickets_in_trac {
+    my $self    = shift;
+    my $tickets = Net::Trac::TicketSearch->new( connection => $trac );
+    my $result  = $tickets->query( summary => { not => 'nonsense' } );
+    my $count   = scalar @{ $tickets->results };
+    return $count;
+}

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



More information about the Bps-public-commit mailing list