[Rt-commit] r6633 - in rt/branches/3.6-RELEASE: . bin
html/REST/1.0/Forms/ticket lib/t/data
falcone at bestpractical.com
falcone at bestpractical.com
Fri Dec 15 10:44:29 EST 2006
Author: falcone
Date: Fri Dec 15 10:44:27 2006
New Revision: 6633
Added:
rt/branches/3.6-RELEASE/lib/t/data/lorem-ipsum
Modified:
rt/branches/3.6-RELEASE/ (props changed)
rt/branches/3.6-RELEASE/bin/rt.in
rt/branches/3.6-RELEASE/html/REST/1.0/Forms/ticket/attachments
rt/branches/3.6-RELEASE/lib/t/regression/26command_line.t
Log:
r15177 at ketch: falcone | 2006-12-15 10:43:44 -0500
* make the command line client remove the trailing newline if we're given non-text content
* if we're returning just a non-text attachment from REST, set the ContentType
* un-TODO tests of adding attachments through the command line interface
* lorem-ipsum simple test attachment text
Modified: rt/branches/3.6-RELEASE/bin/rt.in
==============================================================================
--- rt/branches/3.6-RELEASE/bin/rt.in (original)
+++ rt/branches/3.6-RELEASE/bin/rt.in Fri Dec 15 10:44:27 2006
@@ -342,7 +342,14 @@
return suggest_help("show", $type) if $bad;
my $r = submit("$REST/show", { id => \@objects, %data });
- print $r->content;
+ my $c = $r->content;
+ # if this isn't a text reply, remove the trailing newline so we
+ # don't corrupt things like tarballs when people do
+ # show ticket/id/attachments/id/content > foo.tar.gz
+ if ($r->content_type !~ /^text\//) {
+ chomp($c);
+ }
+ print $c;
}
# To create a new object, we ask the server for a form with the defaults
Modified: rt/branches/3.6-RELEASE/html/REST/1.0/Forms/ticket/attachments
==============================================================================
--- rt/branches/3.6-RELEASE/html/REST/1.0/Forms/ticket/attachments (original)
+++ rt/branches/3.6-RELEASE/html/REST/1.0/Forms/ticket/attachments Fri Dec 15 10:44:27 2006
@@ -80,7 +80,12 @@
return [ "# Invalid attachment id: $aid", [], {}, 1 ];
}
if ($content) {
- $c = $attachment->OriginalContent;
+ $c = $attachment->OriginalContent;
+ # if we're sending a binary attachment (and only the attachment)
+ # flag it so bin/rt knows to special case it
+ if ($attachment->ContentType !~ /^text\//) {
+ $r->content_type($attachment->ContentType);
+ }
} else {
my @data;
push @data, [ id => $attachment->Id ];
Added: rt/branches/3.6-RELEASE/lib/t/data/lorem-ipsum
==============================================================================
--- (empty file)
+++ rt/branches/3.6-RELEASE/lib/t/data/lorem-ipsum Fri Dec 15 10:44:27 2006
@@ -0,0 +1,5 @@
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut
+labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
+nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit
+esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
+culpa qui officia deserunt mollit anim id est laborum.
Modified: rt/branches/3.6-RELEASE/lib/t/regression/26command_line.t
==============================================================================
--- rt/branches/3.6-RELEASE/lib/t/regression/26command_line.t (original)
+++ rt/branches/3.6-RELEASE/lib/t/regression/26command_line.t Fri Dec 15 10:44:27 2006
@@ -3,7 +3,7 @@
use strict;
use Test::Expect;
#use Test::More qw/no_plan/;
-use Test::More tests => 192;
+use Test::More tests => 202;
use RT;
RT::LoadConfig();
@@ -38,7 +38,7 @@
$RT::Logger->debug("Connecting to server at $RT::WebBaseURL...");
$ENV{'RTSERVER'} = $RT::WebBaseURL;
# - RTDEBUG Numeric debug level. (Set to 3 for full logs.)
-$ENV{'RTDEBUG'} = '3';
+$ENV{'RTDEBUG'} = '1';
# - RTCONFIG Specifies a name other than ".rtrc" for the
# configuration file.
#
@@ -98,13 +98,12 @@
expect_send("correspond -m 'correspond-$$' $ticket_id", "Adding correspondence...");
expect_like(qr/Message recorded/, "Added the correspondence");
### should test to make sure it actually got added
-TODO: {
- local $TODO = "Adding attachments is broken right now";
+
# add attachments to a ticket
- expect_send("comment -m 'attach file' $rt_tool_path $ticket_id", "Adding an attachment");
- expect_like(qr/Message recorded/, "Added the attachment");
- ### should test to make sure it actually got added
-}
+ # text attachment
+ check_attachment("$RT::BasePath/lib/t/data/lorem-ipsum");
+ # binary attachment
+ check_attachment("$RT::BasePath/html/NoAuth/images/bplogo.gif");
# change a ticket's Owner
expect_send("edit ticket/$ticket_id set owner=root", 'Changing owner...');
@@ -397,4 +396,23 @@
return $id;
}
+# wrap up all the file handling stuff for attachment testing
+sub check_attachment {
+ my $attachment_path = shift;
+ (my $filename = $attachment_path) =~ s/.*\/(.*?)$/$1/;
+ expect_send("comment -m 'attach file' -a $attachment_path $ticket_id", "Adding an attachment ($filename)");
+ expect_like(qr/Message recorded/, "Added the attachment");
+ expect_send("show ticket/$ticket_id/attachments","Finding Attachment");
+ my $attachment_regex = qr/(\d+):\s+$filename/;
+ expect_like($attachment_regex,"Attachment Uploaded");
+ expect_handle->before() =~ $attachment_regex;
+ my $attachment_id = $1;
+ expect_send("show ticket/$ticket_id/attachments/$attachment_id/content","Fetching Attachment");
+ open (my $fh, $attachment_path) or die "Can't open $attachment_path: $!";
+ my $attachment_content = do { local($/); <$fh> };
+ close $fh;
+ chomp $attachment_content;
+ expect_is($attachment_content,"Attachment contains original text");
+}
+
1;
More information about the Rt-commit
mailing list