[Rt-commit] rt branch, 4.2/attach-from-transactions, updated. rt-4.0.1-401-g4ad6fdf

Thomas Sibley trs at bestpractical.com
Thu Aug 11 18:26:33 EDT 2011


The branch, 4.2/attach-from-transactions has been updated
       via  4ad6fdfcb1cb90ab9a62b46223a916156e9fa729 (commit)
       via  d8877810cc4900fda296319e52333ff39f7e295e (commit)
      from  ea61a555cc95a4423d8a94f1aa32751f88704a71 (commit)

Summary of changes:
 share/html/Ticket/Elements/AddAttachments          |    3 +-
 .../NoAuth/images/bpslogo.png => t/data/image.png  |  Bin 3929 -> 3929 bytes
 t/data/owls.jpg                                    |  Bin 0 -> 49171 bytes
 t/web/attach-from-txn.t                            |  125 ++++++++++++++++++++
 4 files changed, 127 insertions(+), 1 deletions(-)
 copy share/html/NoAuth/images/bpslogo.png => t/data/image.png (100%)
 create mode 100644 t/data/owls.jpg
 create mode 100644 t/web/attach-from-txn.t

- Log -----------------------------------------------------------------
commit d8877810cc4900fda296319e52333ff39f7e295e
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Aug 11 18:25:30 2011 -0400

    Consistently order the existing attachment checkboxes by name
    
    Uses the same order as /Ticket/Elements/ShowAttachments.

diff --git a/share/html/Ticket/Elements/AddAttachments b/share/html/Ticket/Elements/AddAttachments
index a8f2878..7bf1081 100644
--- a/share/html/Ticket/Elements/AddAttachments
+++ b/share/html/Ticket/Elements/AddAttachments
@@ -79,7 +79,8 @@ if ($QuoteTransaction) {
     my $txn = RT::Transaction->new( $session{'CurrentUser'} );
     $txn->Load($QuoteTransaction);
     if ($txn->Id and $txn->CurrentUserCanSee) {
-        @quoted_attachments = grep { defined $_->Filename and length $_->Filename }
+        @quoted_attachments = sort { lc($a->Filename) cmp lc($b->Filename) }
+                              grep { defined $_->Filename and length $_->Filename }
                                   @{$txn->Attachments->ItemsArrayRef};
     }
 }

commit 4ad6fdfcb1cb90ab9a62b46223a916156e9fa729
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Aug 11 18:26:20 2011 -0400

    Tests for the new RT-Attach functionality

diff --git a/t/data/image.png b/t/data/image.png
new file mode 100644
index 0000000..8a87374
Binary files /dev/null and b/t/data/image.png differ
diff --git a/t/data/owls.jpg b/t/data/owls.jpg
new file mode 100644
index 0000000..33c6558
Binary files /dev/null and b/t/data/owls.jpg differ
diff --git a/t/web/attach-from-txn.t b/t/web/attach-from-txn.t
new file mode 100644
index 0000000..eef1a46
--- /dev/null
+++ b/t/web/attach-from-txn.t
@@ -0,0 +1,125 @@
+use strict;
+
+use RT::Test tests => 46;
+
+my $LogoName    = 'image.png';
+my $ImageName   = 'owls.jpg';
+my $LogoFile    = RT::Test::get_relocatable_file($LogoName, '..', 'data');
+my $ImageFile   = RT::Test::get_relocatable_file($ImageName, '..', 'data');
+
+# reply to ticket = nothing
+# reply to correspond = getting the right list
+# maintaining the checked ones
+# storing the header
+# getting attached to mail
+# showing up in the web history
+
+my ($baseurl, $m) = RT::Test->started_ok;
+ok $m->login, 'logged in';
+
+my $queue = RT::Queue->new(RT->Nobody);
+my $qid = $queue->Load('General');
+ok( $qid, "Loaded General queue" );
+
+# Create ticket
+$m->form_name('CreateTicketInQueue');
+$m->field('Queue', $qid);
+$m->field('Requestors', 'owls at localhost');
+$m->submit;
+is($m->status, 200, "request successful");
+$m->content_contains("Create a new ticket", 'ticket create page');
+
+$m->form_name('TicketCreate');
+$m->field('Subject', 'Attachments test');
+$m->field('Content', 'Some content');
+$m->submit;
+is($m->status, 200, "request successful");
+
+$m->content_contains('Attachments test', 'we have subject on the page');
+$m->content_contains('Some content', 'and content');
+
+# Reply with uploaded attachments
+$m->follow_link_ok({text => 'Reply'}, "reply to the ticket");
+$m->content_lacks('AttachExisting');
+$m->form_name('TicketUpdate');
+$m->field('Attach', $LogoFile);
+$m->click('AddMoreAttach');
+is($m->status, 200, "request successful");
+
+$m->form_name('TicketUpdate');
+$m->field('Attach', $ImageFile);
+$m->field('UpdateContent', 'Message');
+$m->click('SubmitTicket');
+is($m->status, 200, "request successful");
+
+$m->content_contains("Download $LogoName", 'page has file name');
+$m->content_contains("Download $ImageName", 'page has file name');
+
+# clear mail catcher
+RT::Test->fetch_caught_mails;
+
+# Reply to first correspondence, including an attachment
+$m->follow_link_ok({text => 'Reply', n => 3}, "reply to the reply");
+$m->content_contains('AttachExisting');
+$m->content_contains($LogoName);
+$m->content_contains($ImageName);
+# check stuff
+$m->form_name('TicketUpdate');
+$m->current_form->find_input('AttachExisting', 'checkbox', 2)->check; # owls.jpg
+$m->click('AddMoreAttach');
+is($m->status, 200, "request successful");
+
+# ensure it's still checked
+$m->form_name('TicketUpdate');
+ok $m->current_form->find_input('AttachExisting', 'checkbox', 2)->value, 'still checked';
+$m->field('UpdateContent', 'Here are some attachments');
+$m->click('SubmitTicket');
+is($m->status, 200, "request successful");
+
+# yep, we got it and processed the header!
+$m->content_contains('Here are some attachments');
+$m->content_like(qr/RT-Attach:.+?\Q$ImageName\E/s, 'found rt attach header');
+
+# outgoing looks good
+$m->follow_link_ok({text => 'Show', n => 3}, "found show link");
+$m->content_like(qr/RT-Attach: \d+/, "found RT-Attach header");
+$m->content_like(qr/RT-Attachment: \d+\/\d+\/\d+/, "found RT-Attachment header");
+$m->content_lacks($ImageName);
+$m->back;
+
+# check that it got into mail
+my @mails = RT::Test->fetch_caught_mails;
+is scalar @mails, 1, "got one outgoing email";
+my $mail = shift @mails;
+like $mail, qr/To: owls\@localhost/, 'got To';
+like $mail, qr/RT-Attach: \d+/, "found attachment we expected";
+like $mail, qr/RT-Attachment: \d+\/\d+\/\d+/, "found RT-Attachment header";
+like $mail, qr/filename=.?\Q$ImageName\E.?/, "found filename";
+
+# add header to template, make a normal reply, and see that it worked
+my $link = $m->find_link(text_regex => qr/\Q$LogoName\E/, url_regex => qr/Attachment/);
+ok $link;
+my ($id) = $link->url =~ /Attachment\/\d+\/(\d+)/;
+ok $id;
+my $template = RT::Template->new( RT->SystemUser );
+$template->LoadGlobalTemplate('Correspondence');
+ok $template->Id;
+$template->SetContent( "RT-Attach: $id\n" . $template->Content );
+like $template->Content, qr/RT-Attach/, "updated template";
+
+# reply...
+$m->follow_link_ok({text => 'Reply'}, "reply to the ticket");
+$m->form_name('TicketUpdate');
+$m->field('UpdateContent', 'who gives a hoot');
+$m->click('SubmitTicket');
+is($m->status, 200, "request successful");
+$m->content_contains('who gives a hoot');
+
+# then see if we got the right mail
+my @mails = RT::Test->fetch_caught_mails;
+is scalar @mails, 1, "got one outgoing email";
+my $mail = shift @mails;
+like $mail, qr/To: owls\@localhost/, 'got To';
+like $mail, qr/RT-Attach: $id/, "found attachment we expected";
+like $mail, qr/RT-Attachment: \d+\/\d+\/$id/, "found RT-Attachment header";
+like $mail, qr/filename=.?\Q$LogoName\E.?/, "found filename";

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


More information about the Rt-commit mailing list