[Rt-commit] rtir branch, 4.0/correspondents-from-makeclicky, created. 4.0.0-61-gdf7fee4a

Brian Duggan brian at bestpractical.com
Thu May 24 17:56:19 EDT 2018


The branch, 4.0/correspondents-from-makeclicky has been created
        at  df7fee4aea1df4db85c6b66a72e155d9b28ebe99 (commit)

- Log -----------------------------------------------------------------
commit 58635136eaea4bccaa8381498e3e9d7c9cea5c10
Author: Brian C. Duggan <brian at bestpractical.com>
Date:   Thu May 24 12:57:09 2018 -0400

    Test for MakeClicky email links on all RTIR ticket types
    
    All RTIR ticket types get 'Lookup email' and 'Lookup email-domain'
    links when MakeClicky email is enabled. This change tests Incident
    Reports, Incidents, Investigations, and Countermeaures for these links
    instead of just Incident Reports.

diff --git a/t/015-make-clicky.t b/t/015-make-clicky.t
index c064fa95..9ea37a5e 100644
--- a/t/015-make-clicky.t
+++ b/t/015-make-clicky.t
@@ -50,65 +50,73 @@ diag "clicky ip" if $ENV{'TEST_VERBOSE'};
 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',
-      )
+    for my $create_method_ref (
+	sub { $agent->create_ir( $_[0] ) },
+	sub { $agent->create_incident( $_[0] ) },
+	sub { $agent->create_investigation( $_[0] ) },
+	sub {
+	    $_[0]{Incident} = $agent->create_incident(@_);
+	    $agent->create_countermeasure( $_[0] );
+	},
+	)
     {
-        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 $email_link = $agent->find_link( url_regex => qr/\Qq=$email\E/, text_regex => qr/\Qlookup email\E$/ );
-        my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
-        $agent->save_content('/tmp/x.html');
-        if ( $clicky{'email'} ) {
-            ok( $email_link,                                   "found link $email_link" );
-            ok( $email_link->url =~ /(?<!\w)\Qq=$email\E(?!\w)/, 'url '.$email_link->url.' has an email - '.$email );
-            ok( $domain_link,                                    "found link" );
-            ok( $domain_link->url =~ /(?<!\w)\Q$domain\E(?!\w)/, 'url has a domain' );
-        }
-        else {
-            ok( !$email_link, "not found email link" );
-            ok( !$domain_link, "not found domain link" );
-        }
-
-    }
-
-    for my $email ( 'foo at example') {
-        diag "test invalid email (invalid domain) $email" if $ENV{TEST_VERBOSE};
-
-        my ( $name, $domain );
-        if ($email =~ /^(.*)@(.*)$/) {
-            ($name,$domain) = ($1,$2);
-        }
-        my $id = $agent->create_ir( { Subject => 'clicky email', Content => $email } );
-        $agent->display_ticket($id);
-        my $email_link = $agent->find_link( url_regex => qr/\Qq=$email\E/, text_regex => qr/\Qlookup email\E$/ );
-        ok( !$email_link, "not found email link for $email" );
-        my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
-        ok( !$domain_link, "not found domain link for $domain" );
-
+	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 =
+		$create_method_ref->( { Subject => 'clicky email', Content => $email } );
+	    $agent->display_ticket($id);
+	    my $email_link = $agent->find_link( url_regex => qr/\Qq=$email\E/, text_regex => qr/\Qlookup email\E$/ );
+	    my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
+	    $agent->save_content('/tmp/x.html');
+	    if ( $clicky{'email'} ) {
+		ok( $email_link,                                   "found link $email_link" );
+		ok( $email_link->url =~ /(?<!\w)\Qq=$email\E(?!\w)/, 'url '.$email_link->url.' has an email - '.$email );
+		ok( $domain_link,                                    "found link" );
+		ok( $domain_link->url =~ /(?<!\w)\Q$domain\E(?!\w)/, 'url has a domain' );
+	    }
+	    else {
+		ok( !$email_link, "not found email link" );
+		ok( !$domain_link, "not found domain link" );
+	    }
+
+	}
+
+	for my $email ( 'foo at example') {
+	    diag "test invalid email (invalid domain) $email" if $ENV{TEST_VERBOSE};
+
+	    my ( $name, $domain );
+	    if ($email =~ /^(.*)@(.*)$/) {
+		($name,$domain) = ($1,$2);
+	    }
+	    my $id = $create_method_ref->( { Subject => 'clicky email', Content => $email } );
+	    $agent->display_ticket($id);
+	    my $email_link = $agent->find_link( url_regex => qr/\Qq=$email\E/, text_regex => qr/\Qlookup email\E$/ );
+	    ok( !$email_link, "not found email link for $email" );
+	    my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
+	    ok( !$domain_link, "not found domain link for $domain" );
+
+	}
+
+	for my $email ( '@example.com' ) {
+	    diag "test invalid email (no local part) $email" if $ENV{TEST_VERBOSE};
+	
+	    my ( $name, $domain );
+	    if ($email =~ /^(.*)@(.*)$/) {
+		($name,$domain) = ($1,$2);
+	    }
+	    my $id = $create_method_ref->( { Subject => 'clicky email', Content => $email } );
+	    $agent->display_ticket($id);
+	    my $email_link = $agent->find_link( url_regex => qr/\Qq=$email\E/, text_regex => qr/\Qlookup email\E$/ );
+	    ok( !$email_link, "not found email link for $email" );
+	    my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
+	    ok( $domain_link, "still found the bare domain for $domain" );
+	}
     }
-
-
-    for my $email ( '@example.com' ) {
-        diag "test invalid email (no local part) $email" if $ENV{TEST_VERBOSE};
-
-        my ( $name, $domain );
-        if ($email =~ /^(.*)@(.*)$/) {
-            ($name,$domain) = ($1,$2);
-        }
-        my $id = $agent->create_ir( { Subject => 'clicky email', Content => $email } );
-        $agent->display_ticket($id);
-        my $email_link = $agent->find_link( url_regex => qr/\Qq=$email\E/, text_regex => qr/\Qlookup email\E$/ );
-        ok( !$email_link, "not found email link for $email" );
-        my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
-        ok( $domain_link, "still found the bare domain for $domain" );
-    }
-
-
 }
 
 diag "utf8 caching " if $ENV{'TEST_VERBOSE'};

commit 1605718ebdb1edd837017e3bbaedf246c3d6265e
Author: Brian C. Duggan <brian at bestpractical.com>
Date:   Thu May 24 14:37:53 2018 -0400

    Test for 'Investigate to' links next to MakeClicky email adddresses
    
    Test for the presence of 'Investigate to' links next to MakeClicky
    email addresses on Incident tickets.

diff --git a/t/015-make-clicky.t b/t/015-make-clicky.t
index 9ea37a5e..e6c0bf76 100644
--- a/t/015-make-clicky.t
+++ b/t/015-make-clicky.t
@@ -70,18 +70,32 @@ diag "clicky email" if $ENV{'TEST_VERBOSE'};
 	    my $id =
 		$create_method_ref->( { Subject => 'clicky email', Content => $email } );
 	    $agent->display_ticket($id);
+
+	    my $is_incident = $agent->text() =~ qr/Queue: Incidents/;
+	    
 	    my $email_link = $agent->find_link( url_regex => qr/\Qq=$email\E/, text_regex => qr/\Qlookup email\E$/ );
 	    my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
+
+	    my $investigate_link = $agent->find_link( url_regex => qr/\QRequestors=$email\E/, 
+						   text_regex => qr/^\Qinvestigate to\E$/i ) if $is_incident;
+	    
 	    $agent->save_content('/tmp/x.html');
 	    if ( $clicky{'email'} ) {
 		ok( $email_link,                                   "found link $email_link" );
 		ok( $email_link->url =~ /(?<!\w)\Qq=$email\E(?!\w)/, 'url '.$email_link->url.' has an email - '.$email );
-		ok( $domain_link,                                    "found link" );
+		ok( $domain_link,                                    "found domain link" );
 		ok( $domain_link->url =~ /(?<!\w)\Q$domain\E(?!\w)/, 'url has a domain' );
+
+		if ( $is_incident ) {
+		    ok( $investigate_link, "found investigate link" );
+		    ok( $investigate_link->url =~ /(?<!\w)\QRequestors=$email\E(?!\w)/,
+			'url '.$investigate_link->url.' has Requestors email' );
+		}
 	    }
 	    else {
 		ok( !$email_link, "not found email link" );
 		ok( !$domain_link, "not found domain link" );
+		ok( !$investigate_link, "not found investigate link") if $is_incident;
 	    }
 
 	}
@@ -95,11 +109,15 @@ diag "clicky email" if $ENV{'TEST_VERBOSE'};
 	    }
 	    my $id = $create_method_ref->( { Subject => 'clicky email', Content => $email } );
 	    $agent->display_ticket($id);
+	    my $is_incident = $agent->text() =~ qr/Queue: Incidents/;
 	    my $email_link = $agent->find_link( url_regex => qr/\Qq=$email\E/, text_regex => qr/\Qlookup email\E$/ );
 	    ok( !$email_link, "not found email link for $email" );
 	    my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
 	    ok( !$domain_link, "not found domain link for $domain" );
-
+	    my $investigate_link = $agent->find_link( url_regex => qr/\QRequestors=$email\E/, 
+						      text_regex => qr/^\Qinvestigate to\E$/i )
+		if $is_incident;
+	    ok( !$investigate_link, "not found investigate link for $email" );
 	}
 
 	for my $email ( '@example.com' ) {
@@ -111,10 +129,15 @@ diag "clicky email" if $ENV{'TEST_VERBOSE'};
 	    }
 	    my $id = $create_method_ref->( { Subject => 'clicky email', Content => $email } );
 	    $agent->display_ticket($id);
+	    my $is_incident = $agent->text() =~ qr/Queue: Incidents/;
 	    my $email_link = $agent->find_link( url_regex => qr/\Qq=$email\E/, text_regex => qr/\Qlookup email\E$/ );
 	    ok( !$email_link, "not found email link for $email" );
 	    my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
 	    ok( $domain_link, "still found the bare domain for $domain" );
+	    my $investigate_link = $agent->find_link( url_regex => qr/\QRequestors=$email\E/, 
+						      text_regex => qr/^\Qinvestigate to\E$/i )
+		if $is_incident;
+	    ok( !$investigate_link, "not found investigate link for $email" );
 	}
     }
 }

commit 8f39472280d36dd112b0257558e680f359f40893
Author: Brian C. Duggan <brian at bestpractical.com>
Date:   Thu May 24 16:07:34 2018 -0400

    Test Correspondents field on 'Investigate to' investigation creation
    
    MakeClicky 'Investigate to' links should load a queue selection page
    for investigation creation.
    
    That queue selection page form should lead to an investigation
    creation page.
    
    The Correspondents field on that investigation creation page should be
    populated with the MakeClicky 'Investigate to' email address.
    
    This change adds tests that test this workflow.

diff --git a/t/015-make-clicky.t b/t/015-make-clicky.t
index e6c0bf76..399cb9c6 100644
--- a/t/015-make-clicky.t
+++ b/t/015-make-clicky.t
@@ -67,6 +67,9 @@ diag "clicky email" if $ENV{'TEST_VERBOSE'};
 	{
 	    diag "test valid email $email" if $ENV{TEST_VERBOSE};
 	    my ( $name, $domain ) = split /@/, $email, 2;
+	    my $uri_escaped_email = $email;
+	    RT::Interface::Web::EscapeURI(\$uri_escaped_email);
+	    
 	    my $id =
 		$create_method_ref->( { Subject => 'clicky email', Content => $email } );
 	    $agent->display_ticket($id);
@@ -76,8 +79,8 @@ diag "clicky email" if $ENV{'TEST_VERBOSE'};
 	    my $email_link = $agent->find_link( url_regex => qr/\Qq=$email\E/, text_regex => qr/\Qlookup email\E$/ );
 	    my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
 
-	    my $investigate_link = $agent->find_link( url_regex => qr/\QRequestors=$email\E/, 
-						   text_regex => qr/^\Qinvestigate to\E$/i ) if $is_incident;
+	    my $investigate_link = $agent->find_link( url_regex => qr/\QRequestors=$uri_escaped_email\E/, 
+						      text_regex => qr/^\Qinvestigate to\E$/i ) if $is_incident;
 	    
 	    $agent->save_content('/tmp/x.html');
 	    if ( $clicky{'email'} ) {
@@ -86,10 +89,29 @@ diag "clicky email" if $ENV{'TEST_VERBOSE'};
 		ok( $domain_link,                                    "found domain link" );
 		ok( $domain_link->url =~ /(?<!\w)\Q$domain\E(?!\w)/, 'url has a domain' );
 
+		# Test that 'Investigate to' links go to the queue selection page for creating incidents.
+		# Then test that the new investigation form on that page loads the investigation creation page.
+		# Then test taht the Correspondents field is populated with the given email address.
 		if ( $is_incident ) {
 		    ok( $investigate_link, "found investigate link" );
-		    ok( $investigate_link->url =~ /(?<!\w)\QRequestors=$email\E(?!\w)/,
+		    ok( $investigate_link->url =~ /(?<!\w)\QRequestors=$uri_escaped_email\E(?!\w)/,
 			'url '.$investigate_link->url.' has Requestors email' );
+		    $agent->follow_link_ok( { url => $investigate_link->url }, 'followed "investigate to" link' );
+		    $agent->title_is( 'Select Queue for New Investigation',
+				      'selecting queue for new investigation' );
+		    $agent->submit_form_ok(
+			{
+			    form_id => 'CreateInQueue',
+			}, 'submitted new investigation form' );
+		    $agent->title_is( 'Launch a new investigation', 'launching a new investigation' );
+                    $agent->form_name( 'TicketCreate' );
+                    my @correspondents = $agent->find_all_inputs(
+                        name => 'Requestors',
+                        type => 'text',
+                        value => $email
+                        );
+                    is( $#correspondents, 0, "correspondents populated with $email");
+		    use Data::Dumper;
 		}
 	    }
 	    else {

commit df7fee4aea1df4db85c6b66a72e155d9b28ebe99
Author: Brian C. Duggan <brian at bestpractical.com>
Date:   Mon May 21 15:59:59 2018 -0400

    Set correspondents from "Investigate to" MakeClicky link
    
    When @Active_MakeClicky contains "email", Incident ticket displays add
    a "Investigate to" link to email addresses in message bodies. The
    "Investigate to" link opens a page that allows the user to select an
    Investigation queue and create a ticket in it. The resulting ticket
    creation page did not set Correspondents at all. It should set
    Correspondents to the value of the email the user clicked "Investigate
    to" on.
    
    This change sets Correspondents to the MakeClicky email address
    on new tickets created from "Investigate to" links.

diff --git a/html/Callbacks/RTIR/Elements/MakeClicky/Default b/html/Callbacks/RTIR/Elements/MakeClicky/Default
index e24b24a5..c6531f7a 100644
--- a/html/Callbacks/RTIR/Elements/MakeClicky/Default
+++ b/html/Callbacks/RTIR/Elements/MakeClicky/Default
@@ -153,6 +153,8 @@ my %actions;
 
         my $email = $args{'value'}; $email =~ s/^<|>$//g;
         my $escaped_email = $escaper->($email);
+	my $uri_escaped_email = $escaped_email;
+	RT::Interface::Web::EscapeURI(\$uri_escaped_email);
 
         my $result = qq{<a class="button" href="}.
             RT::IR->HREFTo(qq{Tools/Lookup.html?$args{'lookup_params'}type=email&q=$escaped_email}). qq{">}
@@ -165,9 +167,9 @@ my %actions;
                 RT::IR->HREFTo( "CreateInQueue.html"
                 . qq{?Incident=$args{'incident'}}
                 . qq{&Lifecycle=}.RT::IR->lifecycle_investigation
-                . "&Requestors=$escaped_email")
+                . "&Requestors=$uri_escaped_email")
                 . qq{">}
-                . loc('Investigate to') .qq{</a>};
+                .loc('Investigate to') .qq{</a>};
         }
         my $domain = (split /@/, $email, 2)[1];
         my $escaped_domain = $escaper->($domain);
diff --git a/html/RTIR/Elements/CreateInRTIRQueueModal b/html/RTIR/Elements/CreateInRTIRQueueModal
index ebb062a0..ade02826 100644
--- a/html/RTIR/Elements/CreateInRTIRQueueModal
+++ b/html/RTIR/Elements/CreateInRTIRQueueModal
@@ -51,6 +51,9 @@
 % }
 % if ($Child) {
 <input type="hidden" name="Child" value="<%$Child%>"/>
+% }
+% if ($Requestors) {
+<input type="hidden" name="Requestors" value="<%$Requestors%>"/>
 % }
   <&|/l_unsafe, $ticket_type,
       $m->scomp('/RTIR/Elements/SelectRTIRQueue',
@@ -95,5 +98,6 @@ my $ticket_type = lc RT::IR::TicketType( Lifecycle => $Lifecycle );
 $Lifecycle
 $Incident => undef
 $Child => undef
+$Requestors => undef
 </%ARGS>
 

-----------------------------------------------------------------------


More information about the rt-commit mailing list