[Bps-public-commit] r17466 - in Net-Trac/trunk: . t
trs at bestpractical.com
trs at bestpractical.com
Tue Dec 30 22:45:28 EST 2008
Author: trs
Date: Tue Dec 30 22:45:28 2008
New Revision: 17466
Modified:
Net-Trac/trunk/ (props changed)
Net-Trac/trunk/lib/Net/Trac/Ticket.pm
Net-Trac/trunk/lib/Net/Trac/TicketAttachment.pm
Net-Trac/trunk/t/attachments.t
Log:
r43316 at zot: tom | 2008-12-30 22:45:20 -0500
* Add a convenience method to access attachment content
* Fix URLs
Modified: Net-Trac/trunk/lib/Net/Trac/Ticket.pm
==============================================================================
--- Net-Trac/trunk/lib/Net/Trac/Ticket.pm (original)
+++ Net-Trac/trunk/lib/Net/Trac/Ticket.pm Tue Dec 30 22:45:28 2008
@@ -245,7 +245,7 @@
connection => $self->connection,
ticket => $self->id
});
- $attachment->_parse_html( $fragment );
+ $attachment->_parse_html_chunk( $fragment );
push @attachments, $attachment;
}
$self->_attachments( \@attachments );
Modified: Net-Trac/trunk/lib/Net/Trac/TicketAttachment.pm
==============================================================================
--- Net-Trac/trunk/lib/Net/Trac/TicketAttachment.pm (original)
+++ Net-Trac/trunk/lib/Net/Trac/TicketAttachment.pm Tue Dec 30 22:45:28 2008
@@ -24,7 +24,7 @@
has author => ( isa => 'Str', is => 'rw' );
has size => ( isa => 'Int', is => 'rw' );
-sub _parse_html {
+sub _parse_html_chunk {
my $self = shift;
my $html = shift;
@@ -36,7 +36,7 @@
# Test description
$self->_fill_property( $html, 'filename', qr{<a (?:.+?) title="View attachment">(.+?)</a>} );
- $self->url( "/attachment/ticket/" . $self->ticket . "/" . $self->filename )
+ $self->url( "/raw-attachment/ticket/" . $self->ticket . "/" . $self->filename )
if defined $self->filename;
$self->_fill_property( $html, size => qr{<span title="(\d+) bytes">} );
@@ -55,6 +55,11 @@
else { warn "Unable to find attachment $prop!" }
}
+sub content {
+ my $self = shift;
+ return $self->connection->_fetch( $self->url );
+}
+
=head1 NAME
Net::Trac::TicketAttachment
Modified: Net-Trac/trunk/t/attachments.t
==============================================================================
--- Net-Trac/trunk/t/attachments.t (original)
+++ Net-Trac/trunk/t/attachments.t Tue Dec 30 22:45:28 2008
@@ -39,7 +39,8 @@
like($ticket->history->entries->[0]->content, qr/I like moose./, "The comment looks correct.");
my ($fh, $filename) = tempfile();
-print $fh "A".."Z", "\n"; # 27 bytes
+my $alpha = join '', 'A'..'Z';
+print $fh "$alpha\n"; # 27 bytes
close $fh;
ok(-e $filename, "temp file exists: $filename");
@@ -52,4 +53,5 @@
is($ticket->attachments->[-1]->author, 'hiro', "Got right author!");
like($filename, qr/\E@{[$ticket->attachments->[-1]->filename]}\E/, "Got right filename!");
is($ticket->attachments->[-1]->description, 'Test description', "Got right description!");
+is($ticket->attachments->[-1]->content, "$alpha\n", "Got right content!");
More information about the Bps-public-commit
mailing list