[Rt-commit] rt branch, 4.0/dashboard-subscriptions, updated. rt-4.0.2-29-g15f2c66
Jason May
jasonmay at bestpractical.com
Fri Aug 26 18:23:06 EDT 2011
The branch, 4.0/dashboard-subscriptions has been updated
via 15f2c6688e0dce07ec29fb3e766e6b2836c76b5b (commit)
via 1cbc1c0aa8407d877e9ff448376a3fa139b1d392 (commit)
from b5e07b6ca10b7a5926769dadc536e4e234878fee (commit)
Summary of changes:
t/mail/dashboards.t | 84 +++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 75 insertions(+), 9 deletions(-)
- Log -----------------------------------------------------------------
commit 1cbc1c0aa8407d877e9ff448376a3fa139b1d392
Author: Jason May <jasonmay at bestpractical.com>
Date: Fri Aug 26 17:26:29 2011 -0400
Factor out functions for deleting dashboards and subscriptions
diff --git a/t/mail/dashboards.t b/t/mail/dashboards.t
index 8b7895c..8e3e4e8 100644
--- a/t/mail/dashboards.t
+++ b/t/mail/dashboards.t
@@ -126,6 +126,29 @@ sub produces_no_dashboard_mail_ok { # {{{
is @mails, 0, $name;
} # }}}
+sub delete_dashboard { # {{{
+ my $dashboard_id = shift;
+ # 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);
+} # }}}
+
+sub delete_subscriptions { # {{{
+ my $subscription_id = shift;
+ # delete the dashboard and make sure we get exactly one subscription failure
+ # notice
+ my $user = RT::User->new(RT->SystemUser);
+ $user->Load('root');
+ for my $subscription ($user->Attributes->Named('Subscription')) {
+ $subscription->Delete;
+ }
+} # }}}
+
my $good_time = 1290423660; # 6:01 EST on a monday
my $bad_time = 1290427260; # 7:01 EST on a monday
@@ -198,14 +221,7 @@ 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);
+delete_dashboard($dashboard_id);
warning_like {
RT::Dashboard::Mailer->MailDashboards(All => 1);
commit 15f2c6688e0dce07ec29fb3e766e6b2836c76b5b
Author: Jason May <jasonmay at bestpractical.com>
Date: Fri Aug 26 17:28:44 2011 -0400
Add tests for M-F dashboard subscriptions
diff --git a/t/mail/dashboards.t b/t/mail/dashboards.t
index 8e3e4e8..fbc9a6b 100644
--- a/t/mail/dashboards.t
+++ b/t/mail/dashboards.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use RT::Test tests => 96;
+use RT::Test tests => 134;
use Test::Warn;
use RT::Dashboard::Mailer;
@@ -266,4 +266,54 @@ 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 => 'm-f',
+ Hour => '06:00',
+);
+
+($dashboard_id, $subscription_id) = get_dash_sub_ids();
+
+# bump $bad_time back to Sunday
+$bad_time = $good_time - 86400;
+
+produces_dashboard_mail_ok(
+ Time => $good_time,
+ Subject => "[example.com] a M-f b Testing! c\n",
+);
+
+produces_no_dashboard_mail_ok(
+ Name => "no mail because it's the wrong time",
+ Time => $bad_time,
+);
+
+produces_no_dashboard_mail_ok(
+ Name => "no mail because it's the wrong time",
+ Time => $bad_time - 86400, # saturday
+);
+
+produces_dashboard_mail_ok(
+ Time => $bad_time - 86400 * 2, # friday
+ Subject => "[example.com] a M-f b Testing! c\n",
+);
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list