[Rt-commit] rt branch, 4.2/web-attachs-processing, updated. rt-3.9.7-1244-g5b133a0

Ruslan Zakirov ruz at bestpractical.com
Fri Mar 4 03:40:52 EST 2011


The branch, 4.2/web-attachs-processing has been updated
       via  5b133a0e9946afdd3c7883f54b0723e5c7f462fe (commit)
       via  559a4d927382321bd85568b5fdd687b0ba4659a3 (commit)
       via  650c6eed651ec395fc5fbac8160b5680d7b547b0 (commit)
       via  dc73c55196b57f060d01bc98bdb17960c030426e (commit)
       via  468dbca2546287195a505bc294698ced0ad1d949 (commit)
       via  5265cb79d37d29d715c7fcb1641da8501d50ef3b (commit)
       via  96c688750f12dde4600166fc58beb4154f15e375 (commit)
       via  0ac0034b7ffa4b1c2a365ef9baba28958f136af0 (commit)
       via  482b999a05bb2d3b566b621ab81e517662bde46c (commit)
       via  1723472c10c3c570186dcd1a27957d79c9468831 (commit)
      from  cb5ff367d24a7bd6f25f01f882f53a453de173ad (commit)

Summary of changes:
 lib/RT/Interface/Web.pm                   |   35 +--
 share/html/Search/Bulk.html               |    2 +-
 share/html/SelfService/Create.html        |    2 +-
 share/html/SelfService/Display.html       |    3 +-
 share/html/SelfService/Update.html        |    4 +-
 share/html/Ticket/Elements/AddAttachments |    7 +-
 share/html/Ticket/ModifyAll.html          |    3 +-
 t/web/attachments.t                       |  423 ++++++++++++++++++++++++++---
 8 files changed, 416 insertions(+), 63 deletions(-)

- Log -----------------------------------------------------------------
commit 1723472c10c3c570186dcd1a27957d79c9468831
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Mar 3 12:22:53 2011 +0300

    minor: don't create more keys in the session

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 15b33e3..9f43067 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1184,7 +1184,7 @@ sub CreateTicket {
 
         delete $session{'Attachments'}{ $ARGS{'Token'} || '' }
             unless $ARGS{'KeepAttachments'};
-        $session{'Attachment'} = $session{'Attachment'}
+        $session{'Attachments'} = $session{'Attachments'}
             if @attachments;
     }
     if ( $ARGS{'Attachments'} ) {

commit 482b999a05bb2d3b566b621ab81e517662bde46c
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Mar 3 12:23:43 2011 +0300

    compile correct list of attachments earlier

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 9f43067..051ac98 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1364,10 +1364,17 @@ sub ProcessUpdateMessage {
         @_
     );
 
-    if ( $args{ARGSRef}->{'UpdateAttachments'}
-        && !keys %{ $args{ARGSRef}->{'UpdateAttachments'} } )
-    {
-        delete $args{ARGSRef}->{'UpdateAttachments'};
+    my @attachments;
+    if ( my $tmp = $session{'Attachments'}{ $args{'ARGSRef'}{'Token'} || '' } ) {
+        push @attachments, grep $_, values %$tmp;
+
+        delete $session{'Attachments'}{ $args{'ARGSRef'}{'Token'} || '' }
+            unless $args{'KeepAttachments'};
+        $session{'Attachments'} = $session{'Attachments'}
+            if @attachments;
+    }
+    if ( $args{ARGSRef}{'UpdateAttachments'} ) {
+        push @attachments, grep $_, values %{ $args{ARGSRef}{'UpdateAttachments'} };
     }
 
     # Strip the signature
@@ -1381,7 +1388,7 @@ sub ProcessUpdateMessage {
     # If, after stripping the signature, we have no message, move the
     # UpdateTimeWorked into adjusted TimeWorked, so that a later
     # ProcessBasics can deal -- then bail out.
-    if (    not $args{ARGSRef}->{'UpdateAttachments'}
+    if (    not @attachments
         and not length $args{ARGSRef}->{'UpdateContent'} )
     {
         if ( $args{ARGSRef}->{'UpdateTimeWorked'} ) {
@@ -1417,18 +1424,6 @@ sub ProcessUpdateMessage {
         );
     }
 
-    my @attachments;
-    if ( my $tmp = $session{'Attachments'}{ $args{'ARGSRef'}{'Token'} || '' } ) {
-        push @attachments, grep $_, values %$tmp;
-
-        delete $session{'Attachments'}{ $args{'ARGSRef'}{'Token'} || '' }
-            unless $args{'KeepAttachments'};
-        $session{'Attachment'} = $session{'Attachment'}
-            if @attachments;
-    }
-    if ( $args{ARGSRef}{'UpdateAttachments'} ) {
-        push @attachments, grep $_, values %{ $args{ARGSRef}{'UpdateAttachments'} };
-    }
     if ( @attachments ) {
         $Message->make_multipart;
         $Message->add_part( $_ ) foreach @attachments;

commit 0ac0034b7ffa4b1c2a365ef9baba28958f136af0
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Mar 3 12:24:47 2011 +0300

    don't forget to update session when we put attachments

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 051ac98..01e6cad 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1540,6 +1540,8 @@ sub ProcessAttachments {
 
         my $file_path = Encode::decode_utf8("$new");
         $session{'Attachments'}{ $token }{ $file_path } = $attachment;
+
+        $update_session = 1;
     }
     $session{'Attachments'} = $session{'Attachments'} if $update_session;
 }

commit 96c688750f12dde4600166fc58beb4154f15e375
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Mar 4 11:35:19 2011 +0300

    pass around Token in Bulk update

diff --git a/share/html/Search/Bulk.html b/share/html/Search/Bulk.html
index ea946e6..9d677b4 100755
--- a/share/html/Search/Bulk.html
+++ b/share/html/Search/Bulk.html
@@ -50,7 +50,7 @@
 
 <& /Elements/ListActions, actions => \@results &>
 <form method="post" action="<% RT->Config->Get('WebPath') %>/Search/Bulk.html" enctype="multipart/form-data" name="BulkUpdate" id="BulkUpdate">
-% foreach my $var (qw(Query Format OrderBy Order Rows Page SavedChartSearchId)) {
+% foreach my $var (qw(Query Format OrderBy Order Rows Page SavedChartSearchId Token)) {
 <input type="hidden" class="hidden" name="<%$var%>" value="<%$ARGS{$var} || ''%>" />
 %}
 <& /Elements/CollectionList, 

commit 5265cb79d37d29d715c7fcb1641da8501d50ef3b
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Mar 4 11:36:00 2011 +0300

    name a few forms to easier test writing

diff --git a/share/html/SelfService/Create.html b/share/html/SelfService/Create.html
index 952de85..17b29f3 100755
--- a/share/html/SelfService/Create.html
+++ b/share/html/SelfService/Create.html
@@ -48,7 +48,7 @@
 <& Elements/Header, Title => loc("Create a ticket") &>
 
 <& /Elements/ListActions, actions => \@results &>
-<form action="Create.html" method="post" enctype="multipart/form-data">
+<form action="Create.html" method="post" enctype="multipart/form-data" name="TicketCreate">
 <input type="hidden" class="hidden" name="id" value="new" />
 
 <table>
diff --git a/share/html/SelfService/Update.html b/share/html/SelfService/Update.html
index 5b83032..750f5a1 100755
--- a/share/html/SelfService/Update.html
+++ b/share/html/SelfService/Update.html
@@ -51,7 +51,7 @@
 
 % $m->callback(CallbackName => 'BeforeForm', %ARGS, ARGSRef => \%ARGS, Ticket => $Ticket );
 
-<form action="Display.html" method="post" enctype="multipart/form-data">
+<form action="Display.html" method="post" enctype="multipart/form-data" name="TicketUpdate">
 <input type="hidden" class="hidden" name="UpdateType" value="response" />
 <input type="hidden" class="hidden" name="id" value="<%$Ticket->Id%>" />
 <table>
diff --git a/share/html/Ticket/ModifyAll.html b/share/html/Ticket/ModifyAll.html
index 436b7cf..6250517 100755
--- a/share/html/Ticket/ModifyAll.html
+++ b/share/html/Ticket/ModifyAll.html
@@ -51,7 +51,7 @@
 % $m->callback(CallbackName => 'BeforeActionList', Actions => \@results, ARGSRef => \%ARGS, Ticket => $Ticket);
 <& /Elements/ListActions, actions => \@results &>
 
-<form method="post" action="ModifyAll.html" enctype="multipart/form-data">
+<form method="post" action="ModifyAll.html" name="TicketUpdate" enctype="multipart/form-data">
 % $m->callback( CallbackName => 'FormStart', ARGSRef => \%ARGS );
 <input type="hidden" class="hidden" name="id" value="<%$Ticket->Id%>" />
 

commit 468dbca2546287195a505bc294698ced0ad1d949
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Mar 4 11:36:52 2011 +0300

    Display.html may be called from another component

diff --git a/share/html/SelfService/Display.html b/share/html/SelfService/Display.html
index 6b0f724..f439264 100755
--- a/share/html/SelfService/Display.html
+++ b/share/html/SelfService/Display.html
@@ -151,7 +151,8 @@ unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
 }
 
 MaybeRedirectForResults(
-    Actions => \@results,
+    Actions   => \@results,
+    Path      => '/SelfService/Display.html',
     Arguments => { 'id' => $Ticket->id },
 );
 

commit dc73c55196b57f060d01bc98bdb17960c030426e
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Mar 4 11:37:52 2011 +0300

    SingleFile argument in AddAttachments for SelfService

diff --git a/share/html/SelfService/Update.html b/share/html/SelfService/Update.html
index 750f5a1..dd0c272 100755
--- a/share/html/SelfService/Update.html
+++ b/share/html/SelfService/Update.html
@@ -72,7 +72,7 @@
         </td>
 
     </tr>
-    <& /Ticket/Elements/AddAttachments, %ARGS, TicketObj => $Ticket &>
+    <& /Ticket/Elements/AddAttachments, %ARGS, TicketObj => $Ticket, SingleFile => 1 &>
 </table>
 <& /Ticket/Elements/EditCustomFields,  TicketObj => $Ticket &>
 <& /Elements/MessageBox, 
diff --git a/share/html/Ticket/Elements/AddAttachments b/share/html/Ticket/Elements/AddAttachments
index d0a8b53..17e65bc 100644
--- a/share/html/Ticket/Elements/AddAttachments
+++ b/share/html/Ticket/Elements/AddAttachments
@@ -56,11 +56,16 @@
 </tr>
 % } # end of if
 
-<tr><td class="label"><&|/l&>Attach</&>:</td><td><input name="Attach" type="file" /><input type="submit" class="button" name="AddMoreAttach" value="<&|/l&>Add More Files</&>" /><input type="hidden" class="hidden" name="UpdateAttach" value="1" />
+<tr><td class="label"><&|/l&>Attach</&>:</td><td><input name="Attach" type="file" />
+% unless ( $SingleFile ) {
+<input type="submit" class="button" name="AddMoreAttach" value="<&|/l&>Add More Files</&>" />
+% }
+<input type="hidden" class="hidden" name="UpdateAttach" value="1" />
 </td></tr>
 
 <%ARGS>
 $Token => ''
+$SingleFile => 0
 </%ARGS>
 <%INIT>
 my $attachments;

commit 650c6eed651ec395fc5fbac8160b5680d7b547b0
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Mar 4 11:38:36 2011 +0300

    pass token in a hidden field

diff --git a/share/html/Ticket/ModifyAll.html b/share/html/Ticket/ModifyAll.html
index 6250517..e49e80e 100755
--- a/share/html/Ticket/ModifyAll.html
+++ b/share/html/Ticket/ModifyAll.html
@@ -54,6 +54,7 @@
 <form method="post" action="ModifyAll.html" name="TicketUpdate" enctype="multipart/form-data">
 % $m->callback( CallbackName => 'FormStart', ARGSRef => \%ARGS );
 <input type="hidden" class="hidden" name="id" value="<%$Ticket->Id%>" />
+<input type="hidden" class="hidden" name="Token" value="<% $Token %>" />
 
 <&| /Widgets/TitleBox, title => loc('Modify ticket # [_1]', $Ticket->Id), class=>'ticket-info-basics' &>
 <& Elements/EditBasics, TicketObj => $Ticket, NoDates => 1 &>

commit 559a4d927382321bd85568b5fdd687b0ba4659a3
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Mar 4 11:39:02 2011 +0300

    get rid of unint warning (self service hits the case)

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 01e6cad..d863b45 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1397,7 +1397,7 @@ sub ProcessUpdateMessage {
         return;
     }
 
-    if ( $args{ARGSRef}->{'UpdateSubject'} eq ($args{'TicketObj'}->Subject || '') ) {
+    if ( ($args{ARGSRef}->{'UpdateSubject'}||'') eq ($args{'TicketObj'}->Subject || '') ) {
         $args{ARGSRef}->{'UpdateSubject'} = undef;
     }
 

commit 5b133a0e9946afdd3c7883f54b0723e5c7f462fe
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Mar 4 11:39:51 2011 +0300

    more tests to cover attachments uploading through the web UI

diff --git a/t/web/attachments.t b/t/web/attachments.t
index 6f175f6..9870f45 100644
--- a/t/web/attachments.t
+++ b/t/web/attachments.t
@@ -1,47 +1,396 @@
 #!/usr/bin/perl -w
 use strict;
 
-use RT::Test tests => 16;
+use RT::Test tests => 112;
 
 use constant LogoFile => $RT::MasonComponentRoot .'/NoAuth/images/bpslogo.png';
 use constant FaviconFile => $RT::MasonComponentRoot .'/NoAuth/images/favicon.png';
 
-my ($baseurl, $m) = RT::Test->started_ok;
+my ($url, $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" );
-
-$m->form_name('CreateTicketInQueue');
-$m->field('Queue', $qid);
-$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('Attach',  LogoFile);
-$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');
-$m->content_contains('Download bpslogo.png', 'page has file name');
-
-$m->follow_link_ok({text => 'Reply'}, "reply to the ticket");
-$m->form_name('TicketUpdate');
-$m->field('Attach',  LogoFile);
-$m->click('AddMoreAttach');
-is($m->status, 200, "request successful");
-
-$m->form_name('TicketUpdate');
-$m->field('Attach',  FaviconFile);
-$m->field('UpdateContent', 'Message');
-$m->click('SubmitTicket');
-is($m->status, 200, "request successful");
-
-$m->content_contains('Download bpslogo.png', 'page has file name');
-$m->content_contains('Download favicon.png', 'page has file name');
+my $queue = RT::Test->load_or_create_queue( Name => 'General' );
+ok( $queue && $queue->id, "Loaded General queue" );
 
+diag "create a ticket in full interface";
+diag "w/o attachments";
+{
+    $m->goto_create_ticket( $queue );
+    is($m->status, 200, "request successful");
+
+    $m->form_name('TicketCreate');
+    $m->content_contains("Create a new ticket", 'ticket create page');
+    $m->submit;
+    is($m->status, 200, "request successful");
+}
+
+diag "with one attachment";
+{
+    $m->goto_create_ticket( $queue );
+
+    $m->form_name('TicketCreate');
+    $m->field('Subject', 'Attachments test');
+    $m->field('Attach',  LogoFile);
+    $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');
+    $m->content_contains('Download bpslogo.png', 'page has file name');
+}
+
+diag "with two attachments";
+{
+    $m->goto_create_ticket( $queue );
+
+    $m->form_name('TicketCreate');
+    $m->field('Attach',  LogoFile);
+    $m->click('AddMoreAttach');
+    is($m->status, 200, "request successful");
+
+    $m->form_name('TicketCreate');
+    $m->field('Attach',  FaviconFile);
+    $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');
+    $m->content_contains('Download bpslogo.png', 'page has file name');
+    $m->content_contains('Download favicon.png', 'page has file name');
+}
+
+diag "with one attachment, but delete one along the way";
+{
+    $m->goto_create_ticket( $queue );
+
+    $m->form_name('TicketCreate');
+    $m->field('Attach',  LogoFile);
+    $m->click('AddMoreAttach');
+    is($m->status, 200, "request successful");
+
+    $m->form_name('TicketCreate');
+    $m->field('Attach',  FaviconFile);
+    $m->tick( 'DeleteAttach', LogoFile );
+    $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');
+    $m->content_lacks('Download bpslogo.png', 'page has file name');
+    $m->content_contains('Download favicon.png', 'page has file name');
+}
+
+diag "with one attachment, but delete one along the way";
+{
+    $m->goto_create_ticket( $queue );
+
+    $m->form_name('TicketCreate');
+    $m->field('Attach',  LogoFile);
+    $m->click('AddMoreAttach');
+    is($m->status, 200, "request successful");
+
+    $m->form_name('TicketCreate');
+    $m->tick( 'DeleteAttach', LogoFile );
+    $m->click('AddMoreAttach');
+    is($m->status, 200, "request successful");
+
+    $m->form_name('TicketCreate');
+    $m->field('Attach',  FaviconFile);
+    $m->click('AddMoreAttach');
+    is($m->status, 200, "request successful");
+
+    $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');
+    $m->content_lacks('Download bpslogo.png', 'page has file name');
+    $m->content_contains('Download favicon.png', 'page has file name');
+}
+
+diag "reply to a ticket in full interface";
+diag "with one attachment";
+{
+    my $ticket = RT::Test->create_ticket(
+        Queue   => $queue,
+        Subject => 'Attachments test',
+        Content => 'Some content',
+    );
+
+    $m->goto_ticket( $ticket->id );
+    $m->follow_link_ok({text => 'Reply'}, "reply to the ticket");
+    $m->form_name('TicketUpdate');
+    $m->field('Attach',  LogoFile);
+    $m->field('UpdateContent', 'Message');
+    $m->click('SubmitTicket');
+    is($m->status, 200, "request successful");
+
+    $m->content_contains('Download bpslogo.png', 'page has file name');
+}
+
+diag "with two attachments";
+{
+    my $ticket = RT::Test->create_ticket(
+        Queue   => $queue,
+        Subject => 'Attachments test',
+        Content => 'Some content',
+    );
+
+    $m->goto_ticket( $ticket->id );
+    $m->follow_link_ok({text => 'Reply'}, "reply to the ticket");
+    $m->form_name('TicketUpdate');
+    $m->field('Attach',  LogoFile);
+    $m->click('AddMoreAttach');
+    is($m->status, 200, "request successful");
+
+    $m->form_name('TicketUpdate');
+    $m->field('Attach',  FaviconFile);
+    $m->field('UpdateContent', 'Message');
+    $m->click('SubmitTicket');
+    is($m->status, 200, "request successful");
+
+    $m->content_contains('Download bpslogo.png', 'page has file name');
+    $m->content_contains('Download favicon.png', 'page has file name');
+}
+
+diag "with one attachment, delete one along the way";
+{
+    my $ticket = RT::Test->create_ticket(
+        Queue   => $queue,
+        Subject => 'Attachments test',
+        Content => 'Some content',
+    );
+
+    $m->goto_ticket( $ticket->id );
+    $m->follow_link_ok({text => 'Reply'}, "reply to the ticket");
+    $m->form_name('TicketUpdate');
+    $m->field('Attach',  LogoFile);
+    $m->click('AddMoreAttach');
+    is($m->status, 200, "request successful");
+
+    $m->form_name('TicketUpdate');
+    $m->tick('DeleteAttach',  LogoFile);
+    $m->field('Attach',  FaviconFile);
+    $m->field('UpdateContent', 'Message');
+    $m->click('SubmitTicket');
+    is($m->status, 200, "request successful");
+
+    $m->content_lacks('Download bpslogo.png', 'page has file name');
+    $m->content_contains('Download favicon.png', 'page has file name');
+}
+
+diag "jumbo interface";
+diag "with one attachment";
+{
+    my $ticket = RT::Test->create_ticket(
+        Queue   => $queue,
+        Subject => 'Attachments test',
+        Content => 'Some content',
+    );
+
+    $m->goto_ticket( $ticket->id );
+    $m->follow_link_ok({text => 'Jumbo'}, "jumbo the ticket");
+    $m->form_name('TicketUpdate');
+    $m->field('Attach',  LogoFile);
+    $m->field('UpdateContent', 'Message');
+    $m->click('SubmitTicket');
+    is($m->status, 200, "request successful");
+
+    $m->goto_ticket( $ticket->id );
+    $m->content_contains('Download bpslogo.png', 'page has file name');
+}
+
+diag "with two attachments";
+{
+    my $ticket = RT::Test->create_ticket(
+        Queue   => $queue,
+        Subject => 'Attachments test',
+        Content => 'Some content',
+    );
+
+    $m->goto_ticket( $ticket->id );
+    $m->follow_link_ok({text => 'Jumbo'}, "jumbo the ticket");
+    $m->form_name('TicketUpdate');
+    $m->field('Attach',  LogoFile);
+    $m->click('AddMoreAttach');
+    is($m->status, 200, "request successful");
+
+    $m->form_name('TicketUpdate');
+    $m->field('Attach',  FaviconFile);
+    $m->field('UpdateContent', 'Message');
+    $m->click('SubmitTicket');
+    is($m->status, 200, "request successful");
+
+    $m->goto_ticket( $ticket->id );
+    $m->content_contains('Download bpslogo.png', 'page has file name');
+    $m->content_contains('Download favicon.png', 'page has file name');
+}
+
+diag "with one attachment, delete one along the way";
+{
+    my $ticket = RT::Test->create_ticket(
+        Queue   => $queue,
+        Subject => 'Attachments test',
+        Content => 'Some content',
+    );
+
+    $m->goto_ticket( $ticket->id );
+    $m->follow_link_ok({text => 'Jumbo'}, "jumbo the ticket");
+    $m->form_name('TicketUpdate');
+    $m->field('Attach',  LogoFile);
+    $m->click('AddMoreAttach');
+    is($m->status, 200, "request successful");
+
+    $m->form_name('TicketUpdate');
+    $m->tick('DeleteAttach',  LogoFile);
+    $m->field('Attach',  FaviconFile);
+    $m->field('UpdateContent', 'Message');
+    $m->click('SubmitTicket');
+    is($m->status, 200, "request successful");
+
+    $m->goto_ticket( $ticket->id );
+    $m->content_lacks('Download bpslogo.png', 'page has file name');
+    $m->content_contains('Download favicon.png', 'page has file name');
+}
+
+diag "bulk update";
+diag "one attachment";
+{
+    my @tickets = RT::Test->create_tickets(
+        {
+            Queue   => $queue,
+            Subject => 'Attachments test',
+            Content => 'Some content',
+        },
+        {},
+        {},
+    );
+    my $query = join ' OR ', map "id=$_", map $_->id, @tickets;
+    $query =~ s/ /%20/g;
+    $m->get_ok( $url . "/Search/Bulk.html?Query=$query&Rows=10" );
+
+    $m->form_name('BulkUpdate');
+    $m->field('Attach',  FaviconFile);
+    $m->field('UpdateContent', 'Message');
+    $m->submit;
+    is($m->status, 200, "request successful");
+
+    foreach my $ticket ( @tickets ) {
+        $m->goto_ticket( $ticket->id );
+        $m->content_lacks('Download bpslogo.png', 'page has file name');
+        $m->content_contains('Download favicon.png', 'page has file name');
+    }
+}
+
+diag "two attachments";
+{
+    my @tickets = RT::Test->create_tickets(
+        {
+            Queue   => $queue,
+            Subject => 'Attachments test',
+            Content => 'Some content',
+        },
+        {},
+        {},
+    );
+    my $query = join ' OR ', map "id=$_", map $_->id, @tickets;
+    $query =~ s/ /%20/g;
+    $m->get_ok( $url . "/Search/Bulk.html?Query=$query&Rows=10" );
+
+    $m->form_name('BulkUpdate');
+    $m->field('Attach',  LogoFile);
+    $m->click('AddMoreAttach');
+    is($m->status, 200, "request successful");
+
+    $m->form_name('BulkUpdate');
+    $m->field('Attach',  FaviconFile);
+    $m->field('UpdateContent', 'Message');
+    $m->submit;
+    is($m->status, 200, "request successful");
+
+    foreach my $ticket ( @tickets ) {
+        $m->goto_ticket( $ticket->id );
+        $m->content_contains('Download bpslogo.png', 'page has file name');
+        $m->content_contains('Download favicon.png', 'page has file name');
+    }
+}
+
+diag "one attachment, delete one along the way";
+{
+    my @tickets = RT::Test->create_tickets(
+        {
+            Queue   => $queue,
+            Subject => 'Attachments test',
+            Content => 'Some content',
+        },
+        {},
+        {},
+    );
+    my $query = join ' OR ', map "id=$_", map $_->id, @tickets;
+    $query =~ s/ /%20/g;
+    $m->get_ok( $url . "/Search/Bulk.html?Query=$query&Rows=10" );
+
+    $m->form_name('BulkUpdate');
+    $m->field('Attach',  LogoFile);
+    $m->click('AddMoreAttach');
+    is($m->status, 200, "request successful");
+
+    $m->form_name('BulkUpdate');
+    $m->tick('DeleteAttach',  LogoFile);
+    $m->field('Attach',  FaviconFile);
+    $m->field('UpdateContent', 'Message');
+    $m->submit;
+    is($m->status, 200, "request successful");
+
+    foreach my $ticket ( @tickets ) {
+        $m->goto_ticket( $ticket->id );
+        $m->content_lacks('Download bpslogo.png', 'page has file name');
+        $m->content_contains('Download favicon.png', 'page has file name');
+    }
+}
+
+diag "self service";
+diag "create with attachment";
+{
+    $m->get_ok( $url . "/SelfService/Create.html?Queue=". $queue->id );
+
+    $m->form_name('TicketCreate');
+    $m->field('Attach',  FaviconFile);
+    $m->field('Content', 'Message');
+    ok(!$m->current_form->find_input('AddMoreAttach'), "one attachment only");
+    $m->submit;
+    is($m->status, 200, "request successful");
+
+    $m->content_contains('Download favicon.png', 'page has file name');
+}
+
+diag "update with attachment";
+{
+    my $ticket = RT::Test->create_ticket(
+        Queue   => $queue,
+        Subject => 'Attachments test',
+        Content => 'Some content',
+    );
+
+    $m->get_ok( $url . "/SelfService/Update.html?id=". $ticket->id );
+    $m->form_name('TicketUpdate');
+    $m->field('Attach',  FaviconFile);
+    $m->field('UpdateContent', 'Message');
+    ok(!$m->current_form->find_input('AddMoreAttach'), "one attachment only");
+    $m->submit;
+    is($m->status, 200, "request successful");
+
+    $m->content_contains('Download favicon.png', 'page has file name');
+}

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


More information about the Rt-commit mailing list