[Rt-commit] rt branch, 4.0/dashboard-subscriptions, updated. rt-4.0.2-32-gd0bda29
Jason May
jasonmay at bestpractical.com
Fri Aug 26 18:50:09 EDT 2011
The branch, 4.0/dashboard-subscriptions has been updated
via d0bda29347af1dd81ad7aaa9dad405ffa4783b58 (commit)
via 58db5263cd6619eac1b066659aff5a6248ed6ac8 (commit)
via 4555db979e98bf71919fb0bb0b3eb096360c2033 (commit)
from 15f2c6688e0dce07ec29fb3e766e6b2836c76b5b (commit)
Summary of changes:
lib/RT/Dashboard/Mailer.pm | 15 +++++++-
t/mail/dashboards.t | 84 ++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 95 insertions(+), 4 deletions(-)
- Log -----------------------------------------------------------------
commit 4555db979e98bf71919fb0bb0b3eb096360c2033
Author: Jason May <jasonmay at bestpractical.com>
Date: Fri Aug 26 18:41:41 2011 -0400
Add tests for monthly dashboard subscriptions
diff --git a/t/mail/dashboards.t b/t/mail/dashboards.t
index fbc9a6b..52bc699 100644
--- a/t/mail/dashboards.t
+++ b/t/mail/dashboards.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use RT::Test tests => 134;
+use RT::Test tests => 164;
use Test::Warn;
use RT::Dashboard::Mailer;
@@ -317,3 +317,47 @@ produces_dashboard_mail_ok(
Time => $bad_time - 86400 * 2, # friday
Subject => "[example.com] a M-f b Testing! c\n",
);
+
+
+ at mails = RT::Test->fetch_caught_mails;
+is(@mails, 0, "no mail leftover");
+
+$m->no_warnings_ok;
+RT::Test->stop_server;
+RT->Config->Set('DashboardSubject' => 'a %s b %s c');
+RT->Config->Set('DashboardAddress' => 'dashboard at example.com');
+RT->Config->Set('EmailDashboardRemove' => (qr/My dashboards/, "Testing!"));
+($baseurl, $m) = RT::Test->started_ok;
+
+delete_dashboard($dashboard_id);
+delete_subscriptions();
+
+RT::Test->clean_caught_mails;
+
+RT::Test->stop_server;
+
+RT->Config->Set('EmailDashboardRemove' => ());
+RT->Config->Set('DashboardAddress' => 'root');
+($baseurl, $m) = RT::Test->started_ok;
+$m->login;
+create_dashboard($baseurl, $m);
+create_subscription($baseurl, $m,
+ Frequency => 'monthly',
+ Hour => '06:00',
+);
+
+($dashboard_id, $subscription_id) = get_dash_sub_ids();
+
+$good_time = 1291201200; # dec 1
+$bad_time = $good_time - 86400; # day before (i.e. different month)
+
+produces_dashboard_mail_ok(
+ Time => $good_time,
+ Subject => "[example.com] a Monthly b Testing! c\n",
+);
+
+produces_no_dashboard_mail_ok(
+ Name => "no mail because it's the wrong time",
+ Time => $bad_time,
+);
+
commit 58db5263cd6619eac1b066659aff5a6248ed6ac8
Author: Jason May <jasonmay at bestpractical.com>
Date: Fri Aug 26 18:48:05 2011 -0400
Add tests for dashboard subscriptions set to 'never'
diff --git a/t/mail/dashboards.t b/t/mail/dashboards.t
index 52bc699..014739e 100644
--- a/t/mail/dashboards.t
+++ b/t/mail/dashboards.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use RT::Test tests => 164;
+use RT::Test tests => 187;
use Test::Warn;
use RT::Dashboard::Mailer;
@@ -361,3 +361,37 @@ produces_no_dashboard_mail_ok(
Time => $bad_time,
);
+
+ at mails = RT::Test->fetch_caught_mails;
+is(@mails, 0, "no mail leftover");
+
+$m->no_warnings_ok;
+RT::Test->stop_server;
+RT->Config->Set('DashboardSubject' => 'a %s b %s c');
+RT->Config->Set('DashboardAddress' => 'dashboard at example.com');
+RT->Config->Set('EmailDashboardRemove' => (qr/My dashboards/, "Testing!"));
+($baseurl, $m) = RT::Test->started_ok;
+
+delete_dashboard($dashboard_id);
+delete_subscriptions();
+
+RT::Test->clean_caught_mails;
+
+RT::Test->stop_server;
+
+RT->Config->Set('EmailDashboardRemove' => ());
+RT->Config->Set('DashboardAddress' => 'root');
+($baseurl, $m) = RT::Test->started_ok;
+$m->login;
+create_dashboard($baseurl, $m);
+create_subscription($baseurl, $m,
+ Frequency => 'never',
+);
+
+($dashboard_id, $subscription_id) = get_dash_sub_ids();
+
+produces_no_dashboard_mail_ok(
+ Name => "mail should never get sent",
+ Time => $bad_time,
+);
+
commit d0bda29347af1dd81ad7aaa9dad405ffa4783b58
Author: Jason May <jasonmay at bestpractical.com>
Date: Fri Aug 26 18:49:03 2011 -0400
Use a loc'd hash instead of ucfirst for frequencies in the dashboard mailer
Some tests were adjusted for this change.
diff --git a/lib/RT/Dashboard/Mailer.pm b/lib/RT/Dashboard/Mailer.pm
index 026ae7c..8878055 100644
--- a/lib/RT/Dashboard/Mailer.pm
+++ b/lib/RT/Dashboard/Mailer.pm
@@ -318,9 +318,22 @@ sub EmailDashboard {
my $currentuser = $args{CurrentUser};
my $email = $args{Email};
+ my $frequency = $subscription->SubValue('Frequency');
+
+ my %frequency_lookup = (
+ 'm-f' => 'Weekday', # loc
+ 'daily' => 'Daily', # loc
+ 'weekly' => 'Weekly', # loc
+ 'monthly' => 'Monthly', # loc
+ 'never' => 'Never', # loc
+ );
+
+ my $frequency_display = $frequency_lookup{$frequency}
+ || $frequency;
+
my $subject = sprintf '[%s] ' . RT->Config->Get('DashboardSubject'),
RT->Config->Get('rtname'),
- ucfirst($subscription->SubValue('Frequency')),
+ $currentuser->loc($frequency_display),
$dashboard->Name;
my $entity = $self->BuildEmail(
diff --git a/t/mail/dashboards.t b/t/mail/dashboards.t
index 014739e..ebf20cc 100644
--- a/t/mail/dashboards.t
+++ b/t/mail/dashboards.t
@@ -300,7 +300,7 @@ $bad_time = $good_time - 86400;
produces_dashboard_mail_ok(
Time => $good_time,
- Subject => "[example.com] a M-f b Testing! c\n",
+ Subject => "[example.com] a Weekday b Testing! c\n",
);
produces_no_dashboard_mail_ok(
@@ -315,7 +315,7 @@ produces_no_dashboard_mail_ok(
produces_dashboard_mail_ok(
Time => $bad_time - 86400 * 2, # friday
- Subject => "[example.com] a M-f b Testing! c\n",
+ Subject => "[example.com] a Weekday b Testing! c\n",
);
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list