[Rt-commit] rt branch, 4.0/correct-message-ids, created. rt-4.0.0-285-g579828a
Thomas Sibley
trs at bestpractical.com
Fri May 13 16:13:44 EDT 2011
The branch, 4.0/correct-message-ids has been created
at 579828a05cd60ddf86dee6c84d420dd13e68c654 (commit)
- Log -----------------------------------------------------------------
commit a516cd5ce77be7bc444fb9b51b71db953963c9da
Author: Thomas Sibley <trs at bestpractical.com>
Date: Fri May 13 15:50:30 2011 -0400
Test our Message-ID generation when creating and updating tickets via the web
Create and update message attachments should have exactly one
Message-ID. Uploaded file attachments shouldn't have any Message-IDs.
diff --git a/t/web/ticket_txn_content.t b/t/web/ticket_txn_content.t
index 176840c..06ea7e7 100644
--- a/t/web/ticket_txn_content.t
+++ b/t/web/ticket_txn_content.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use RT::Test tests => 39;
+use RT::Test tests => 63;
use File::Temp 'tempfile';
use File::Spec;
my ( $plain_fh, $plain_file ) =
@@ -25,6 +25,20 @@ ok( $qid, "Loaded General queue" );
RT::Test->clean_caught_mails;
+sub follow_parent_with_headers_link {
+ my $m = shift;
+ my $link = $m->find_link(@_)->url;
+ $link =~ s{/(\d+)$}{"/" . ($1-1)}e; # get the parent attach
+ $m->get_ok($baseurl . $link);
+}
+
+sub follow_with_headers_link {
+ my $m = shift;
+ my $link = $m->find_link(@_)->url;
+ $link =~ s{/\d+/(\d+)/.+$}{/WithHeaders/$1}; # frob into a with headers url
+ $m->get_ok($baseurl . $link);
+}
+
for my $type ( 'text/plain', 'text/html' ) {
$m->form_name('CreateTicketInQueue');
$m->field( 'Queue', $qid );
@@ -44,6 +58,16 @@ for my $type ( 'text/plain', 'text/html' ) {
$m->content_contains('this is main content', 'main content' );
$m->content_contains("Download $plain_name", 'download plain file link' );
+ # Check for Message-IDs
+ follow_parent_with_headers_link($m, text => 'with headers', n => 1);
+ $m->content_like(qr/^Message-ID:/im, 'create content has one Message-ID');
+ $m->content_unlike(qr/^Message-ID:.+?Message-ID:/ism, 'but not two Message-IDs');
+ $m->back;
+
+ follow_with_headers_link($m, text => "Download $plain_name", n => 1);
+ $m->content_unlike(qr/^Message-ID:/im, 'attachment lacks a Message-ID');
+ $m->back;
+
my ( $mail ) = RT::Test->fetch_caught_mails;
like( $mail, qr/this is main content/, 'email contains main content' );
# check the email link in page too
@@ -69,6 +93,20 @@ for my $type ( 'text/plain', 'text/html' ) {
$m->content_contains("this is main reply content", 'main reply content' );
$m->content_contains("Download $html_name", 'download html file link' );
+ # Check for Message-IDs
+ follow_parent_with_headers_link($m, text => 'with headers', n => 2);
+ $m->content_like(qr/^Message-ID:/im, 'correspondence has one Message-ID');
+ $m->content_unlike(qr/^Message-ID:.+?Message-ID:/ism, 'but not two Message-IDs');
+ $m->back;
+
+ follow_with_headers_link($m, text => "Download $plain_name", n => 2);
+ $m->content_unlike(qr/^Message-ID:/im, 'text/plain attach lacks a Message-ID');
+ $m->back;
+
+ follow_with_headers_link($m, text => "Download $html_name", n => 1);
+ $m->content_unlike(qr/^Message-ID:/im, 'text/html attach lacks a Message-ID');
+ $m->back;
+
( $mail ) = RT::Test->fetch_caught_mails;
like( $mail, qr/this is main reply content/, 'email contains main reply content' );
# check the email link in page too
commit b055fafce46c74cf4cd0cfd0e13b44b8cbc236fd
Author: Thomas Sibley <trs at bestpractical.com>
Date: Fri May 13 15:52:23 2011 -0400
Avoid two different Message-IDs on update transactions via the web
MakeMIMEEntity sets a default Message-ID since 129baa2. Rather than add
another Message-ID in ProcessUpdateMessages, replace the default.
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index fd0bf20..bd17f32 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1483,7 +1483,7 @@ sub ProcessUpdateMessage {
Type => $args{ARGSRef}->{'UpdateContentType'},
);
- $Message->head->add( 'Message-ID' => Encode::encode_utf8(
+ $Message->head->replace( 'Message-ID' => Encode::encode_utf8(
RT::Interface::Email::GenMessageId( Ticket => $args{'TicketObj'} )
) );
my $old_txn = RT::Transaction->new( $session{'CurrentUser'} );
commit 579828a05cd60ddf86dee6c84d420dd13e68c654
Author: Thomas Sibley <trs at bestpractical.com>
Date: Fri May 13 15:54:46 2011 -0400
Remove the default Message-ID if we're making an entity for a file upload
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index bd17f32..98e4dde 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1658,6 +1658,9 @@ sub MakeMIMEEntity {
if ( !$args{'Subject'} && !( defined $args{'Body'} && length $args{'Body'} ) ) {
$Message->head->set( 'Subject' => $filename );
}
+
+ # Attachment parts really shouldn't get a Message-ID
+ $Message->head->delete('Message-ID');
}
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list