[Bps-public-commit] SD branch, master, updated. 0.70-22-g954c863
jesse
jesse at bestpractical.com
Tue Sep 1 19:08:43 EDT 2009
The branch, master has been updated
via 954c863776b34060c20cf191e09e671e2a8e94a6 (commit)
via b3cc86338aa96d7e5d5728f1df084f143923db07 (commit)
from e69f08d6d1b653390e9d7cd1947bb9a9cb6fedca (commit)
Summary of changes:
lib/App/SD/CLI/Dispatcher.pm | 2 +-
lib/App/SD/Replica/trac/PushEncoder.pm | 11 ++++---
t/sd-trac/push-comment.t | 49 ++++++++++++++++++++++++--------
3 files changed, 44 insertions(+), 18 deletions(-)
- Log -----------------------------------------------------------------
commit b3cc86338aa96d7e5d5728f1df084f143923db07
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Tue Sep 1 18:49:08 2009 -0400
made "sd help attach" work
diff --git a/lib/App/SD/CLI/Dispatcher.pm b/lib/App/SD/CLI/Dispatcher.pm
index fcbaa1e..3a518d2 100644
--- a/lib/App/SD/CLI/Dispatcher.pm
+++ b/lib/App/SD/CLI/Dispatcher.pm
@@ -36,7 +36,7 @@ under help => sub {
on [ ['author', 'authors'] ] => run_command('Help::Authors');
on [ ['environment', 'env'] ] => run_command('Help::Environment');
on [ ['ticket', 'tickets'] ] => run_command('Help::Tickets');
- on [ ['attachment', 'attachments'] ] => run_command('Help::Attachments');
+ on [ ['attach', 'attachment', 'attachments'] ] => run_command('Help::Attachments');
on [ ['comment', 'comments'] ] => run_command('Help::Comments');
on [ ['setting', 'settings'] ] => run_command('Help::Settings');
on [ ['history', 'log'] ] => run_command('Help::History');
commit 954c863776b34060c20cf191e09e671e2a8e94a6
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Tue Sep 1 19:08:28 2009 -0400
Now we can push attachments to trac! And we _test_ them
diff --git a/lib/App/SD/Replica/trac/PushEncoder.pm b/lib/App/SD/Replica/trac/PushEncoder.pm
index 15a9f58..adb3da9 100644
--- a/lib/App/SD/Replica/trac/PushEncoder.pm
+++ b/lib/App/SD/Replica/trac/PushEncoder.pm
@@ -62,20 +62,21 @@ sub integrate_comment {
}
sub integrate_attachment {
- my ($self, $change, $changeset ) = validate_pos( @_, { isa => 'App::SD::Replica::rt::PushEncoder'}, { isa => 'Prophet::Change' }, { isa => 'Prophet::ChangeSet' });
+ my ($self, $change, $changeset ) = validate_pos( @_, { isa => 'App::SD::Replica::trac::PushEncoder'}, { isa => 'Prophet::Change' }, { isa => 'Prophet::ChangeSet' });
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 $ticket_id = $self->sync_source->remote_id_for_uuid( $props{'ticket'} );
+ my $ticket = Net::Trac::Ticket->new( connection => $self->sync_source->trac);
+ $ticket->load($ticket_id);
my $tempdir = File::Temp::tempdir( CLEANUP => 1 );
my $file = File::Spec->catfile( $tempdir, ( $props{'name'} || 'unnamed' ) );
open my $fh, '>', $file or die $!;
print $fh $props{content};
close $fh;
- my %content = ( message => '(See attachments)', attachments => ["$file"]);
- $ticket->correspond(%content);
+ $ticket->attach( file => $file) || die "Could not attach file for ticket $ticket_id";
return $ticket_id;
}
diff --git a/t/sd-trac/push-comment.t b/t/sd-trac/push-comment.t
index 5c894a5..309643a 100644
--- a/t/sd-trac/push-comment.t
+++ b/t/sd-trac/push-comment.t
@@ -14,7 +14,7 @@ unless (`which trac-admin`) { plan skip_all => 'You need trac installed to run t
unless ( eval { require Net::Trac } ) {
plan skip_all => 'You need Net::Trac installed to run the tests';
}
-plan tests => 17;
+plan tests => 21;
use_ok('Net::Trac::Connection');
use_ok('Net::Trac::Ticket');
@@ -79,21 +79,46 @@ 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."]);
+test_push_of_comment();
+test_push_of_attachment();
+sub test_push_of_attachment {
-ok(!($?>>8), $err);
+ my ($fh, $filename) = File::Temp::tempfile(SUFFIX => '.txt');
+ print $fh "TIMTOWTDI\n";
+ close $fh;
+ sleep 2; # to make trac happy
+ ( $ret, $out, $err )
+ = run_script( 'sd', [ 'ticket', 'attachment', 'create', $yatta_id, '--file', $filename ] );
-($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./);
+ 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' } );
+ is( $tickets->results->[0]->attachments->[0]->content, 'TIMTOWTDI' );
+}
+
+sub test_push_of_comment {
+
+ ( $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 {
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list