[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.9.7-941-ga9a2c17
Shawn Moore
sartak at bestpractical.com
Fri Dec 17 17:32:44 EST 2010
The branch, 3.9-trunk has been updated
via a9a2c1761c7e395dda0ef7317af63912fbc9bc6b (commit)
via 95a0aee21a62b6cb9844e4322189dff46ce1d976 (commit)
via 50882d94614fa68819e78b75b0d6e90bf8b47805 (commit)
from d044a16487a7e023bbaeee17846cbce119f54a0a (commit)
Summary of changes:
lib/RT/Dashboard/Mailer.pm | 4 +++
lib/RT/Interface/Email.pm | 4 +++
t/mail/dashboards.t | 45 ++++++++++++++++++++++++++++++++++++++-----
3 files changed, 47 insertions(+), 6 deletions(-)
- Log -----------------------------------------------------------------
commit 50882d94614fa68819e78b75b0d6e90bf8b47805
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Dec 17 17:29:16 2010 -0500
Allow setting additional headers in SendEmailUsingTemplate
diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index f5168c0..183263f 100755
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -582,6 +582,7 @@ sub SendEmailUsingTemplate {
Bcc => undef,
From => RT->Config->Get('CorrespondAddress'),
InReplyTo => undef,
+ ExtraHeaders => {},
@_
);
@@ -597,6 +598,9 @@ sub SendEmailUsingTemplate {
$mail->head->set( $_ => Encode::encode_utf8( $args{ $_ } ) )
foreach grep defined $args{$_}, qw(To Cc Bcc From);
+ $mail->head->set( $_ => $args{ExtraHeaders}{$_} )
+ foreach keys %{ $args{ExtraHeaders} };
+
SetInReplyTo( Message => $mail, InReplyTo => $args{'InReplyTo'} );
return SendEmail( Entity => $mail );
commit 95a0aee21a62b6cb9844e4322189dff46ce1d976
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Dec 17 17:29:28 2010 -0500
Add X-RT-Dashboard headers for missing dashboard mail
diff --git a/lib/RT/Dashboard/Mailer.pm b/lib/RT/Dashboard/Mailer.pm
index 6d5148c..c4678c0 100644
--- a/lib/RT/Dashboard/Mailer.pm
+++ b/lib/RT/Dashboard/Mailer.pm
@@ -280,6 +280,10 @@ sub ObsoleteSubscription {
Arguments => {
SubscriptionObj => $subscription,
},
+ ExtraHeaders => {
+ 'X-RT-Dashboard-Subscription-Id' => $subscription->Id,
+ 'X-RT-Dashboard-Id' => $subscription->SubValue('DashboardId'),
+ },
);
# only delete the subscription if the email looks like it went through
commit a9a2c1761c7e395dda0ef7317af63912fbc9bc6b
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Dec 17 17:32:14 2010 -0500
Tests for the missing dashboard notice
diff --git a/t/mail/dashboards.t b/t/mail/dashboards.t
index bf02b33..96ec745 100644
--- a/t/mail/dashboards.t
+++ b/t/mail/dashboards.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use RT::Test tests => 63;
+use RT::Test tests => 73;
use RT::Dashboard::Mailer;
my ($baseurl, $m) = RT::Test->started_ok;
@@ -60,7 +60,8 @@ my $user = RT::User->new(RT->SystemUser);
$user->Load('root');
ok($user->Id, 'loaded user');
my ($subscription) = $user->Attributes->Named('Subscription');
-ok($subscription->Id, 'loaded subscription');
+my $subscription_id = $subscription->Id;
+ok($subscription_id, 'loaded subscription');
my $dashboard_id = $subscription->SubValue('DashboardId');
ok($dashboard_id, 'got dashboard id');
@@ -77,8 +78,8 @@ sub produces_dashboard_mail_ok { # {{{
my $mail = parse_mail( $mails[0] );
is($mail->head->get('Subject'), "[example.com] Daily Dashboard: Testing!\n");
is($mail->head->get('From'), "root\n");
- is($mail->head->get('X-RT-Dashboard-Id'), $dashboard_id . "\n");
- is($mail->head->get('X-RT-Dashboard-Subscription-Id'), $subscription->Id . "\n");
+ is($mail->head->get('X-RT-Dashboard-Id'), "$dashboard_id\n");
+ is($mail->head->get('X-RT-Dashboard-Subscription-Id'), "$subscription_id\n");
SKIP: {
skip 'Weird MIME failure', 2;
@@ -156,8 +157,8 @@ is(@mails, 1, "one mail");
my $mail = parse_mail($mails[0]);
is($mail->head->get('Subject'), "[example.com] a Daily b Testing! c\n");
is($mail->head->get('From'), "dashboard\@example.com\n");
-is($mail->head->get('X-RT-Dashboard-Id'), $dashboard_id . "\n");
-is($mail->head->get('X-RT-Dashboard-Subscription-Id'), $subscription->Id . "\n");
+is($mail->head->get('X-RT-Dashboard-Id'), "$dashboard_id\n");
+is($mail->head->get('X-RT-Dashboard-Subscription-Id'), "$subscription_id\n");
SKIP: {
skip 'Weird MIME failure', 2;
@@ -166,3 +167,35 @@ SKIP: {
unlike($body, qr{Testing!});
};
+# delete the dashboard and make sure we get exactly one subscription failure
+# notice
+my $dashboard = RT::Dashboard->new(RT::CurrentUser->new('root'));
+my ($ok, $msg) = $dashboard->LoadById($dashboard_id);
+ok($ok, $msg);
+
+($ok, $msg) = $dashboard->Delete;
+ok($ok, $msg);
+
+do {
+ my @warnings;
+ local $SIG{__WARN__} = sub {
+ push @warnings, "@_";
+ };
+
+ RT::Dashboard::Mailer->MailDashboards(All => 1);
+
+ is(@warnings, 1, "one warning");
+ like($warnings[0], qr/Unable to load dashboard $dashboard_id of subscription $subscription_id for user root/);
+};
+
+ at mails = RT::Test->fetch_caught_mails;
+is(@mails, 1, "one mail for subscription failure");
+$mail = parse_mail($mails[0]);
+is($mail->head->get('Subject'), "[example.com] Missing dashboard!\n");
+is($mail->head->get('From'), "dashboard\@example.com\n");
+is($mail->head->get('X-RT-Dashboard-Id'), "$dashboard_id\n");
+is($mail->head->get('X-RT-Dashboard-Subscription-Id'), "$subscription_id\n");
+
+RT::Dashboard::Mailer->MailDashboards(All => 1);
+ at mails = RT::Test->fetch_caught_mails;
+is(@mails, 0, "no mail because the subscription notice happens only once");
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list