[Rt-commit] rt branch, librarize-send-dashboards, updated. rt-3.9.4-539-g0cba1ae
Shawn Moore
sartak at bestpractical.com
Mon Nov 22 16:17:14 EST 2010
The branch, librarize-send-dashboards has been updated
via 0cba1ae8a4342c357375eda47a42ead1657bd936 (commit)
via 3f06c6b90360d64f071ef34fe46193a5299c5ad3 (commit)
from 64f52f950ac391136b7277fd732579f141bb0671 (commit)
Summary of changes:
lib/RT/Dashboard/Mailer.pm | 4 +-
t/mail/{extractsubjecttag.t => dashboards.t} | 73 ++++++++++++++++++++------
2 files changed, 59 insertions(+), 18 deletions(-)
copy t/mail/{extractsubjecttag.t => dashboards.t} (57%)
- Log -----------------------------------------------------------------
commit 3f06c6b90360d64f071ef34fe46193a5299c5ad3
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Nov 22 15:54:58 2010 -0500
Kick down some log levels in dashboard mailing
diff --git a/lib/RT/Dashboard/Mailer.pm b/lib/RT/Dashboard/Mailer.pm
index 7d92628..32c3078 100644
--- a/lib/RT/Dashboard/Mailer.pm
+++ b/lib/RT/Dashboard/Mailer.pm
@@ -68,7 +68,7 @@ sub MailDashboards {
@_,
);
- $RT::Logger->info("Using time $args{Time} for dashboard generation");
+ $RT::Logger->debug("Using time $args{Time} for dashboard generation");
my $from = $self->GetFrom();
$RT::Logger->debug("Sending email from $from");
@@ -417,7 +417,7 @@ sub GetResource {
my $uri = URI->new(shift);
my ($content, $filename, $mimetype, $encoding);
- $RT::Logger->info("Getting resource $uri");
+ $RT::Logger->debug("Getting resource $uri");
# strip out the equivalent of WebURL, so we start at the correct /
my $path = $uri->path;
commit 0cba1ae8a4342c357375eda47a42ead1657bd936
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Nov 22 16:16:51 2010 -0500
First pass at tests for dashboard mail
diff --git a/t/mail/dashboards.t b/t/mail/dashboards.t
new file mode 100644
index 0000000..634f7b0
--- /dev/null
+++ b/t/mail/dashboards.t
@@ -0,0 +1,131 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use RT::Test tests => 17;
+use RT::Dashboard::Mailer;
+
+my ($baseurl, $m) = RT::Test->started_ok;
+RT::Test->set_mail_catcher;
+ok($m->login, 'logged in');
+
+# first, create and populate a dashboard
+$m->get_ok('/Dashboards/Modify.html?Create=1');
+$m->form_name('ModifyDashboard');
+$m->field('Name' => 'Testing!');
+$m->click_button(value => 'Create');
+$m->title_is('Modify the dashboard Testing!');
+
+$m->follow_link_ok({text => 'Content'});
+$m->title_is('Modify the queries of dashboard Testing!');
+
+my $form = $m->form_name('Dashboard-Searches-body');
+my @input = $form->find_input('Searches-body-Available');
+my ($dashboards_component) =
+ map { ( $_->possible_values )[1] }
+ grep { ( $_->value_names )[1] =~ 'Dashboards' } @input;
+$form->value('Searches-body-Available' => $dashboards_component );
+$m->click_button(name => 'add');
+$m->content_contains('Dashboard updated');
+
+$m->follow_link_ok({text => 'Show'});
+$m->title_is('Dashboard Testing!');
+$m->content_contains('My dashboards');
+$m->content_like(qr{<a href="/Dashboards/\d+/Testing!">Testing!</a>});
+
+# now test the mailer
+
+# without a subscription..
+RT::Dashboard::Mailer->MailDashboards();
+
+my @mails = RT::Test->fetch_caught_mails;
+is @mails, 0, 'no mail yet';
+
+RT::Dashboard::Mailer->MailDashboards(
+ All => 1,
+);
+
+ at mails = RT::Test->fetch_caught_mails;
+is @mails, 0, "no mail yet since there's no subscription";
+
+# create a subscription
+$m->follow_link_ok({text => 'Subscription'});
+$m->title_is('Subscribe to dashboard Testing!');
+$m->form_name('SubscribeDashboard');
+$m->click_button(name => 'Save');
+$m->content_contains("Subscribed to dashboard Testing!");
+
+RT::Dashboard::Mailer->MailDashboards(
+ All => 1,
+);
+
+ at mails = RT::Test->fetch_caught_mails;
+is @mails, 1, "got a dashboard mail";
+
+__END__
+
+
+my $original_ticket = RT::Ticket->new( RT->SystemUser );
+diag "Create a ticket and make sure it has the subject tag";
+{
+ $original_ticket->Create(
+ Queue => $queue->id,
+ Subject => 'test',
+ Requestor => 'root at localhost'
+ );
+ my @mails = RT::Test->fetch_caught_mails;
+ ok @mails, "got some outgoing emails";
+
+ my $status = 1;
+ foreach my $mail ( @mails ) {
+ my $entity = parse_mail( $mail );
+ my $subject = $entity->head->get('Subject');
+ $subject =~ /\[\Q$subject_tag\E #\d+\]/
+ or do { $status = 0; diag "wrong subject: $subject" };
+ }
+ ok $status, "Correctly added subject tag to ticket";
+}
+
+
+diag "Test that a reply with a Subject Tag doesn't change the subject";
+{
+ my $ticketid = $original_ticket->Id;
+ my $text = <<EOF;
+From: root\@localhost
+To: general\@$RT::rtname
+Subject: [$subject_tag #$ticketid] test
+
+reply with subject tag
+EOF
+ my ($status, $id) = RT::Test->send_via_mailgate($text, queue => $queue->Name);
+ is ($status >> 8, 0, "The mail gateway exited normally");
+ is ($id, $ticketid, "Replied to ticket $id correctly");
+
+ my $freshticket = RT::Ticket->new( RT->SystemUser );
+ $freshticket->LoadById($id);
+ is($original_ticket->Subject,$freshticket->Subject,'Stripped Queue Subject Tag correctly');
+
+}
+
+diag "Test that a reply with another RT's subject tag changes the subject";
+{
+ my $ticketid = $original_ticket->Id;
+ my $text = <<EOF;
+From: root\@localhost
+To: general\@$RT::rtname
+Subject: [$subject_tag #$ticketid] [remote-rt-system #79] test
+
+reply with subject tag and remote rt subject tag
+EOF
+ my ($status, $id) = RT::Test->send_via_mailgate($text, queue => $queue->Name);
+ is ($status >> 8, 0, "The mail gateway exited normally");
+ is ($id, $ticketid, "Replied to ticket $id correctly");
+
+ my $freshticket = RT::Ticket->new( RT->SystemUser );
+ $freshticket->LoadById($id);
+ like($freshticket->Subject,qr/\[remote-rt-system #79\]/,"Kept remote rt's subject tag");
+ unlike($freshticket->Subject,qr/\[\Q$subject_tag\E #$ticketid\]/,'Stripped Queue Subject Tag correctly');
+
+}
+
+
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list