[Rt-commit] rtir branch, 2.5-trunk, updated. 2.6.0-4-g7988d32
? sunnavy
sunnavy at bestpractical.com
Mon Jan 3 23:01:49 EST 2011
The branch, 2.5-trunk has been updated
via 7988d32e0d567221efabc710b1c50489e50fa689 (commit)
from 7d275277df3233467005c9cf6a97295b0e99c36a (commit)
Summary of changes:
html/Callbacks/RTIR/Elements/MakeClicky/Default | 2 +-
t/015-make-clicky.t | 52 ++++++++++++++++++++++-
2 files changed, 52 insertions(+), 2 deletions(-)
- Log -----------------------------------------------------------------
commit 7988d32e0d567221efabc710b1c50489e50fa689
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Jan 4 12:00:19 2011 +0800
allow all the 2+ letter tlds for email and test for this
diff --git a/html/Callbacks/RTIR/Elements/MakeClicky/Default b/html/Callbacks/RTIR/Elements/MakeClicky/Default
index 0adfe9e..7e04396 100644
--- a/html/Callbacks/RTIR/Elements/MakeClicky/Default
+++ b/html/Callbacks/RTIR/Elements/MakeClicky/Default
@@ -112,7 +112,7 @@ my @types = (
},
{
name => "email",
- regex => qr{(?:mailto:)?<?[\w\.\+-]+\@[\w\.-]+\.\w{2,3}>?},
+ regex => qr{(?:mailto:)?<?[\w\.\+-]+\@[\w\.-]+\.\w{2,}>?},
action => "email",
},
{
diff --git a/t/015-make-clicky.t b/t/015-make-clicky.t
index d1942ae..9035b71 100644
--- a/t/015-make-clicky.t
+++ b/t/015-make-clicky.t
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use RT::IR::Test tests => 38;
+use RT::IR::Test tests => 94;
RT::Test->started_ok;
my $agent = default_agent();
@@ -47,3 +47,53 @@ diag "clicky ip" if $ENV{'TEST_VERBOSE'};
ok(!grep( lc $_->text eq 'lookup ip', @links ), "not found link");
}
+diag "clicky email" if $ENV{'TEST_VERBOSE'};
+{
+
+ for my $email (
+ 'foo at example.com', 'foo-bar+baz at example.me',
+ 'foo at example.mobi', 'foo at localhost.localhost',
+ )
+ {
+ diag "test valid email $email" if $ENV{TEST_VERBOSE};
+ my ( $name, $domain ) = split /@/, $email, 2;
+ my $id =
+ $agent->create_ir( { Subject => 'clicky email', Content => $email } );
+ $agent->display_ticket($id);
+ my @links = $agent->followable_links;
+ if ( $clicky{'email'} ) {
+ my ($email_link) = grep lc $_->text eq 'lookup email', @links;
+ ok( $email_link, "found link" );
+ ok( $email_link->url =~ /(?<!\w)\Q$email\E(?!\w)/,
+ 'url has an email' );
+
+ my ($domain_link) = grep lc $_->text eq qq{lookup "$domain"},
+ @links;
+ ok( $domain_link, "found link" );
+ ok( $domain_link->url =~ /(?<!\w)\Q$domain\E(?!\w)/,
+ 'url has a domain' );
+ }
+ else {
+ ok( !grep( lc $_->text eq 'lookup email', @links ),
+ "not found email link" );
+ ok( !grep( lc $_->text eq qq{lookup "$domain"}, @links ),
+ "not found domain link" );
+ }
+
+ }
+
+ for my $email ( 'foo at example', '@example.com', ) {
+ diag "test invalid email $email" if $ENV{TEST_VERBOSE};
+
+ my ( $name, $domain ) = split /@/, $email, 2;
+ my $id =
+ $agent->create_ir( { Subject => 'clicky email', Content => $email } );
+ $agent->display_ticket($id);
+ my @links = $agent->followable_links;
+ ok( !grep( lc $_->text eq 'lookup email', @links ),
+ "not found email link" );
+ ok( !grep( lc $_->text eq qq{lookup "$domain"}, @links ),
+ "not found domain link" );
+ }
+}
+
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list