/, "Check for msg div" );
# Make sure we have headers for each of the four kinds of changes.
for my $header ('Log Message', 'Modified Paths', 'Added Paths',
'Removed Paths', 'Property Changed') {
like( $email, qr{
}, "HTML $header" );
}
# Check that we have the commit metatdata.
like( $email, qr|
\n|,
'Check Date');
# Check that the log message is there.
UTF8: {
use utf8;
like( $email, qr{
}, 'Check for HTML log message' );
}
# Make sure that Class/Meta.pm is listed twice, once for modification and once
# for its attribute being set.
is( scalar @{[$email =~ m{(
)}g]}, 2,
'Check for two HTML Class/Meta.pm');
# For other file names, there should be only one instance.
is( scalar @{[$email =~ m{(
)}g]}, 1,
'Check for one HTML Class/Meta/Class.pm');
is( scalar @{[$email =~ m{(
)}g]}, 1,
'Check for one HTML Class/Meta/Type.pm');
# Make sure that no diff is included.
unlike( $email, qr{Modified: trunk/Params-CallbackRequest/Changes},
"Check for html diff" );
##############################################################################
# Make sure that handler delegation and css_url works.
##############################################################################
ok( $notifier = SVN::Notify->new(%args, handler => 'HTML', css_url => 'foo.css'),
"Construct new HTML notifier" );
isa_ok($notifier, 'SVN::Notify::HTML');
isa_ok($notifier, 'SVN::Notify');
ok( $notifier->prepare, "Single method call prepare" );
ok( $notifier->execute, "HTML notify" );
# Get the output.
$email = get_output();
# Check the email headers.
like( $email, qr/Subject: \[111\] $qsubj\n/, 'Check HTML subject' );
like( $email, qr/From: theory\n/, 'Check HTML From');
like( $email, qr/To: test\@example\.com\n/, 'Check HTML To');
like( $email, qr{Content-Type: text/html; charset=UTF-8\n},
'Check HTML Content-Type' );
like( $email, qr{Content-Transfer-Encoding: 8bit\n},
'Check HTML Content-Transfer-Encoding');
like( $email, qr|
|,
'There should be a link rel="stylesheet" tag');
##############################################################################
# Include HTML diff and language.
##############################################################################
ok( $notifier = SVN::Notify::HTML->new(%args, with_diff => 1, language => 'en_US'),
"Construct new HTML diff notifier" );
isa_ok($notifier, 'SVN::Notify::HTML');
isa_ok($notifier, 'SVN::Notify');
NO_BADLANG: {
local $ENV{PERL_BADLANG} = 0;
ok( $notifier->prepare, "Single method call prepare" );
ok( $notifier->execute, "HTML diff notify" );
}
# Get the output.
$email = get_output();
like( $email, qr/Subject: \[111\] $qsubj\n/, 'Check HTML subject' );
like( $email, qr/From: theory\n/, 'Check HTML diff From');
like( $email, qr/To: test\@example\.com\n/, 'Check HTML diff To');
# Make sure there are no attachment headers
is( scalar @{[ $email =~ m{Content-Type: text/(plain|html); charset=UTF-8\n} ]}, 1,
'Check for one HTML Content-Type header' );
is( scalar @{[$email =~ m{Content-Transfer-Encoding: 8bit\n}g]}, 1,
'Check for one HTML Content-Transfer-Encoding header');
is( scalar @{[$email =~ m{Content-Language: en_US\n}g]}, 1,
'Check for one HTML Content-Language header');
# Check for the html header.
like( $email, qr||,
"Check for HTML tag" );
# Make sure that the diff is included and escaped.
like( $email, qr/
/, "Check for patch div" );
like( $email, qr{Modified: trunk/Params-CallbackRequest/Changes},
"Check for diff" );
# Make sure that it's not attached.
unlike( $email, qr{Content-Type: multipart/mixed; boundary=},
"Check for no html diff attachment" );
unlike( $email, qr{Content-Disposition: attachment; filename=},
"Check for no html diff filename" );
like( $email, qr{isa =\> ('|')Apache\1,}, "Check for HTML escaping" );
# Make sure that the file names have links into the diff.
like( $email,
qr|
trunk/Params-CallbackRequest/Changes\n|,
"Check for file name link." );
like( $email,
qr|
trunk/Class-Meta/t/\n|,
"Check for directory name." );
like( $email,
qr|
Modified: trunk/Params-CallbackRequest/Changes\n|,
"Check for file name anchor id" );
like( $email,
qr|
Added: trunk/Params-CallbackRequest/lib/Params/Callback\.pm\n|,
"Check for added file name anchor id" );
##############################################################################
# Attach diff.
##############################################################################
ok( $notifier = SVN::Notify::HTML->new(%args, attach_diff => 1,
boundary => 'frank'),
"Construct new HTML attach diff notifier" );
isa_ok($notifier, 'SVN::Notify::HTML');
isa_ok($notifier, 'SVN::Notify');
ok( $notifier->prepare, "Single method call prepare" );
ok( $notifier->execute, "Attach HTML attach diff notify" );
# Get the output.
$email = get_output();
like( $email, qr/Subject: \[111\] $qsubj\n/,
"Check HTML attach diff subject" );
like( $email, qr/From: theory\n/, 'Check HTML attach diff From');
like( $email, qr/To: test\@example\.com\n/, 'Check HTML attach diff To');
# Make sure we have two sets of headers for attachments.
is( scalar @{[ $email =~ m{Content-Type: text/(plain|html); charset=UTF-8\n}g ]}, 2,
'Check for two Content-Type headers' );
is( scalar @{[$email =~ m{Content-Transfer-Encoding: 8bit\n}g]}, 2,
'Check for two Content-Transfer-Encoding headers');
# No language, so no xml:lang.
like( $email, qr||,
"Check for attach diff HTML tag" );
# Make sure that the diff is included.
like( $email, qr{Modified: trunk/Params-CallbackRequest/Changes},
"Check for diff" );
# Make sure that it's attached.
like( $email, qr{Content-Type: multipart/mixed; boundary="(.*)"\n},
"Check for html diff attachment" );
like( $email,
qr{Content-Disposition: attachment; filename=r111-theory.diff\n},
"Check for html diff filename" );
unlike( $email, qr{
\nModified}, "Check for no pre tag" );
# Check for boundaries.
is( scalar @{[$email =~ m{(--frank\n)}g]}, 2,
'Check for two boundaries');
is( scalar @{[$email =~ m{(--frank--)}g]}, 1,
'Check for one final boundary');
##############################################################################
# Try max_diff_length
#############################################################################
ok $notifier = SVN::Notify::HTML->new(
%args,
max_diff_length => 1024,
with_diff => 1,
), 'Construct new max_diff_length notifier';
isa_ok $notifier, 'SVN::Notify';
isa_ok $notifier, 'SVN::Notify::HTML';
is $notifier->max_diff_length, 1024, 'max_diff_hlength should be set';
ok $notifier->with_diff, 'with_diff should be set';
ok $notifier->prepare, 'Prepare max_diff_length checking';
ok $notifier->execute, 'Notify max_diff_length checking';
# Check the output.
$email = get_output();
like $email, qr{Use Apache::RequestRec for mod_perl 2},
'Check for the last diff line';
unlike $email, qr{ BEGIN }, 'Check for missing extra line';
like $email, qr{Diff output truncated at 1024 characters.},
'Check for truncation message';
##############################################################################
# Try html format with a single file changed.
##############################################################################
ok( $notifier = SVN::Notify::HTML->new(%args, revision => '222'),
"Construct new HTML file notifier" );
isa_ok($notifier, 'SVN::Notify::HTML');
isa_ok($notifier, 'SVN::Notify');
ok( $notifier->prepare, "Prepare HTML file" );
ok( $notifier->execute, "Notify HTML file" );
# Check the output.
$email = get_output();
like( $email, qr{Subject: \[222\] Hrm hrm\. Let's try a few links\.\n},
"Check subject header for HTML file" );
like( $email, qr/From: theory\n/, 'Check HTML file From');
like( $email, qr/To: test\@example\.com\n/, 'Check HTML file To');
like( $email, qr{Content-Type: text/html; charset=UTF-8\n},
'Check HTML file Content-Type' );
like( $email, qr{Content-Transfer-Encoding: 8bit\n},
'Check HTML file Content-Transfer-Encoding');
##############################################################################
# Try viewcvs_url + HTML.
##############################################################################
ok( $notifier = SVN::Notify::HTML->new(%args,
viewcvs_url => 'http://svn.example.com/?rev=%s&view=rev',
),
"Construct new HTML viewcvs_url notifier" );
isa_ok($notifier, 'SVN::Notify::HTML');
isa_ok($notifier, 'SVN::Notify');
ok( $notifier->prepare, "Prepare HTML viewcvs_url" );
ok( $notifier->execute, "Notify HTML viewcvs_url" );
# Check the output.
$email = get_output();
like( $email,
qr|Revision\s+
111\n|,
'Check for HTML URL');
##############################################################################
# Try encoding.
##############################################################################
ok( $notifier = SVN::Notify::HTML->new(%args, encoding => 'ISO-8859-1'),
"Construct new encoding notifier" );
isa_ok($notifier, 'SVN::Notify::HTML');
isa_ok($notifier, 'SVN::Notify');
ok( $notifier->prepare, "Prepare encoding" );
ok( $notifier->execute, "Notify encoding" );
# Check the output.
$email = get_output();
like( $email, qr{Content-Type: text/html; charset=ISO-8859-1\n},
'Check Content-Type charset' );
##############################################################################
# Try html format with propsets.
##############################################################################
ok( $notifier = SVN::Notify::HTML->new(%args, with_diff => 1, revision => '333'),
"Construct new HTML propset notifier" );
isa_ok($notifier, 'SVN::Notify::HTML');
isa_ok($notifier, 'SVN::Notify');
ok( $notifier->prepare, "Prepare HTML propset" );
ok( $notifier->execute, "Notify HTML propset" );
# Check the output.
$email = get_output();
like( $email, qr{Subject: \[333\] Property modification\.\n},
"Check subject header for propset HTML" );
like( $email, qr/From: theory\n/, 'Check HTML propset From');
like( $email, qr/To: test\@example\.com\n/, 'Check HTML propset To');
like( $email, qr{Content-Type: text/html; charset=UTF-8\n},
'Check HTML propset Content-Type' );
like( $email, qr{Content-Transfer-Encoding: 8bit\n},
'Check HTML propset Content-Transfer-Encoding');
like( $email,
qr|
Modified: trunk/activitymail/bin/activitymail\n|,
"Check for file name anchor id" );
like( $email,
qr|
Property changes on: trunk/activitymail/t/activitymail\.t\n|,
"Check for propset file name anchor id" );
##############################################################################
# Try linkize and Bug tracking URLs.
##############################################################################
ok( $notifier = SVN::Notify::HTML->new(
%args,
revision => 222,
viewcvs_url => 'http://viewsvn.bricolage.cc/?rev=%s&view=rev',
rt_url => 'http://rt.cpan.org/NoAuth/Bugs.html?id=%s',
bugzilla_url => 'http://bugzilla.mozilla.org/show_bug.cgi?id=%s',
jira_url => 'http://jira.atlassian.com/secure/ViewIssue.jspa?key=%s',
gnats_url => 'http://gnats.example.com/gnatsweb.pl?cmd=view&pr=%s',
ticket_url => 'http://ticket.example.com/id=%s',
ticket_regex => '\[?\s*(Custom\s*#\s*(\d+))\s*\]?',
),
"Construct new HTML URL notifier" );
isa_ok($notifier, 'SVN::Notify::HTML');
isa_ok($notifier, 'SVN::Notify');
ok( $notifier->prepare, "Prepare HTML URL" );
ok( $notifier->execute, "Notify HTML URL" );
$email = get_output();
# Check linkize results.
like($email, qr|
foo\@example\.com|,
"Check for linked email address");
like($email, qr{
http://www\.kineticode\.com/},
"Check for linked URL" );
like($email,
qr{
http://foo\.bar\.com/one/two/do\.pl\?this=1&that=2},
"Check for fancy linked URL" );
# Check for application URLs.
like( $email,
qr|
Revision\s+
222\n|,
'Check for main ViewCVS URL');
like($email,
qr{
Ticket # 4321},
"Check for RT URL");
like($email,
qr{
Revision # 606},
"Check for log mesage ViewCVS URL");
like( $email,
qr{
Bug # 709},
"Check for Bugzilla URL" );
like( $email,
qr{
PRJ1234-111},
"Check for Jira URL" );
like( $email,
qr{
PR 12345},
"Check for GNATS URL" );
like( $email,
qr{
Custom # 4321},
"Check for custom ticket URL" );
##############################################################################
# Major linkize and Bug tracking URLs, as well as complex diff.
##############################################################################
ok( $notifier = SVN::Notify::HTML->new(
%args,
with_diff => 1,
revision => 444,
viewcvs_url => 'http://viewsvn.bricolage.cc/?rev=%s&view=rev',
rt_url => 'http://rt.cpan.org/NoAuth/Bugs.html?id=%s',
bugzilla_url => 'http://bugzilla.mozilla.org/show_bug.cgi?id=%s',
jira_url => 'http://jira.atlassian.com/secure/ViewIssue.jspa?key=%s',
ticket_url => 'http://ticket.example.com/id=%s',
ticket_regex => '\[?\s*(Custom\s*#\s*(\d+))\s*\]?',
),
"Construct new complex notifier" );
isa_ok($notifier, 'SVN::Notify::HTML');
isa_ok($notifier, 'SVN::Notify');
ok( $notifier->prepare, "Prepare complex example" );
ok( $notifier->execute, "Notify complex example" );
$email = get_output();
# Make sure multiple lines are still multiple!
like($email, qr/link\.\n\nWe/, "Check for multiple lines" );
# Check linkize results.
like($email, qr|
recipient\@example\.com\.|,
"Check for linked email address");
like($email, qr{
http://www\.kineticode\.com/\!},
"Check for linked URL" );
like($email,
qr{
http://www\.example\.com/my\.pl\?one=1&two=2&f=w\*\*t\.},
"Check for fancy linked URL" );
# Check for RT URLs.
like($email,
qr{
Ticket # 6,},
"Check for first RT URL");
like($email,
qr{
Ticket\n12,},
"Check for split RT URL");
unlike($email,
qr{
ticket 69},
"Check for no Ticket 69 URL");
like($email,
qr{
RT-Ticket: #23},
"Check for Jesse's RT URL");
like($email,
qr{
RT #45},
"Check for Ask's RT URL");
# Check for ViewCVS URLs.
like( $email,
qr|
Revision\s+
444\n|,
'Check for main ViewCVS URL');
like($email,
qr{
Revision 6000\.},
"Check for first log mesage ViewCVS URL");
like($email,
qr{
rev\n6001\.},
"Check for split line log mesage ViewCVS URL");
unlike($email,
qr{
rev 200,},
"Check for no rev 200 ViewCVS URL");
# Check for Bugzilla URLs.
like( $email,
qr{
Bug # 1234},
"Check for first Bugzilla URL" );
like( $email,
qr{
bug 8,},
"Check for second Bugzilla URL" );
unlike( $email,
qr{
bug 3\.},
"Check for no humbug URL" );
like( $email,
qr{
Bug\n#4321},
"Check for split line Bugzilla URL" );
# Check for JIRA URLs.
like( $email,
qr{
TST1234-111\.},
"Check for Jira URL" );
unlike( $email,
qr{
JRA-\n4321-1234},
"Check for no split line Jira URL" );
unlike( $email,
qr{
studlyCAPS-1234\.},
"Check for no studlyCAPS Jira URL" );
# Check for custom ticket URLs.
like( $email,
qr{
Custom # 54321},
"Check for custom ticket URL" );
##############################################################################
# SVNWeb URL.
##############################################################################
ok( $notifier = SVN::Notify::HTML->new(
%args,
revision => 444,
svnweb_url => 'http://svn.example.com/index.cgi/revision/?rev=%s',
),
"Construct new notifier for svnweb" );
isa_ok($notifier, 'SVN::Notify::HTML');
isa_ok($notifier, 'SVN::Notify');
ok( $notifier->prepare, "Prepare svnweb example" );
ok( $notifier->execute, "Notify svnweb example" );
$email = get_output();
# Make sure multiple lines are still multiple!
like($email, qr/link\.\n\nWe/, "Check for multiple lines" );
# Check for SVNWeb URLs.
like( $email,
qr|
Revision\s+
444\n|,
'Check for main SVNWeb URL');
like($email,
qr{
Revision 6000\.},
"Check for first log mesage SVNWeb URL");
like($email,
qr{
rev\n6001\.},
"Check for split line log mesage SVNWeb URL");
unlike($email,
qr{
rev 200,},
"Check for no rev 200 SVNWeb URL");
##############################################################################
# Author URL.
##############################################################################
ok( $notifier = SVN::Notify::HTML->new(
%args,
revision => 444,
author_url => 'http://svn.example.com/~%s/',
),
"Construct new notifier for author URL" );
isa_ok($notifier, 'SVN::Notify::HTML');
isa_ok($notifier, 'SVN::Notify');
ok( $notifier->prepare, "Prepare author URL example" );
ok( $notifier->execute, "Notify author URL example" );
$email = get_output();
# Check for Author URL.
like( $email,
qr|
Author\s+
theory\n|,
'Check for Author URL');
##############################################################################
# Try header and footer.
##############################################################################
ok $notifier = SVN::Notify::HTML->new(
%args,
header => 'This is the &header',
footer => 'This is the &footer',
), 'Construct new header and foot notifier';
isa_ok($notifier, 'SVN::Notify::HTML');
isa_ok $notifier, 'SVN::Notify';
is $notifier->header, 'This is the &header', 'Check the header';
is $notifier->footer, 'This is the &footer', 'Check the footer';
ok $notifier->prepare, 'Prepare header and footer checking';
ok $notifier->execute, 'Notify header and footer checking';
# Check the output.
$email = get_output();
like $email, qr{\n
},
'Check for the header';
like $email,
qr{\s+
\s+},
'Check for the footer';
##############################################################################
# Try HTML header and footer.
##############################################################################
ok $notifier = SVN::Notify::HTML->new(
%args,
header => '
',
), 'Construct new HTML header and foot notifier';
isa_ok($notifier, 'SVN::Notify::HTML');
isa_ok $notifier, 'SVN::Notify';
is $notifier->header, '
', 'Check the footer';
ok $notifier->prepare, 'Prepare HTML header and footer checking';
ok $notifier->execute, 'Notify HTML header and footer checking';
# Check the output.
$email = get_output();
like $email, qr{\n