[Rt-commit] [rtir] 19/22: Start to forwardport some constituency tests

Jesse Vincent jesse at bestpractical.com
Sun Mar 29 02:51:05 EDT 2015


This is an automated email from the git hooks/post-receive script.

jesse pushed a commit to branch 3.4/remove_old_constituencies
in repository rtir.

commit 3e22359769120054b474b4149b547632e5176920
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Sat Mar 28 23:16:22 2015 -0700

    Start to forwardport some constituency tests
---
 t/constituency/propagation-reject.t | 111 ++++++++++++++++++------------------
 1 file changed, 56 insertions(+), 55 deletions(-)

diff --git a/t/constituency/propagation-reject.t b/t/constituency/propagation-reject.t
index fbde32e..9a4fbb5 100644
--- a/t/constituency/propagation-reject.t
+++ b/t/constituency/propagation-reject.t
@@ -3,32 +3,46 @@
 use strict;
 use warnings;
 
-use Test::More skip_all => 'constituencies being rebuilt';
 use RT::IR::Test tests => undef;
 
 use_ok('RT::IR');
-RT->Config->Set('_RTIR_Constituency_Propagation' => 'reject');
+RT->Config->Set('RTIR_StrictConstituencyLinking'=> 1);
 
+for my $constituency ('EDUNET','GOVNET') {
+    my $path = RT::Plugin->new( name => 'RT::IR' )->Path( 'bin' ) . "/add_constituency";
+    diag("running $path to set up EDUNET and GOVNET constituencies");
+
+        my ($exit_code, $output) = RT::Test->run_and_capture(
+                command     => $path,
+                name        => $constituency,
+                force       => 1,
+                quiet       => 1,
+            );
+         ok(!$exit_code, "created constituency $constituency");
+         diag "output: $output";
+
+}
 my $cf;
 diag "load the field" if $ENV{'TEST_VERBOSE'};
 {
     my $cfs = RT::CustomFields->new( $RT::SystemUser );
-    $cfs->Limit( FIELD => 'Name', VALUE => 'Constituency', CASESENSITIVE => 0 );
+    $cfs->Limit( FIELD => 'Name', VALUE => 'RTIR Constituency', CASESENSITIVE => 0 );
     $cf = $cfs->First;
     ok $cf, 'have a field';
     ok $cf->id, 'with some ID';
 }
 
 RT::Test->started_ok;
-my $agent = default_agent();
 my $rtir_user = rtir_user();
+my $agent = default_agent();
 
 diag "create an IR with GOVNET constituency and create a new "
     . "incident for the IR, we want it to inherit by default"
         if $ENV{'TEST_VERBOSE'};
 {
-    my $ir_id = $agent->create_ir(
-        { Subject => "test" }, { Constituency => 'GOVNET' }
+    my $ir_id = $agent->create_rtir_ticket_ok(
+        'Incident Reports - GOVNET',
+        { Subject => "test" },
     );
     ok $ir_id, "created IR #$ir_id";
     $agent->display_ticket( $ir_id);
@@ -40,16 +54,16 @@ diag "create an IR with GOVNET constituency and create a new "
     my $ticket = RT::Ticket->new( $RT::SystemUser );
     $ticket->Load( $inc_id );
     ok $ticket->id, 'loaded ticket';
-    is uc $ticket->FirstCustomFieldValue('Constituency'),
-        'GOVNET', 'correct value';
+    is $ticket->QueueObj->Name,
+        'Incidents - GOVNET', 'correct value';
 }
 
 diag "create an IR and check that we couldn't change constituency"
     ." value during creation of new linked incident" if $ENV{'TEST_VERBOSE'};
 {
     # create an IR
-    my $ir_id = $agent->create_ir(
-        { Subject => "test" }, { Constituency => 'GOVNET' }
+    my $ir_id = $agent->create_rtir_ticket_ok('Incident Reports - GOVNET',
+        { Subject => "test" },
     );
     ok $ir_id, "created ticket #$ir_id";
     $agent->display_ticket( $ir_id);
@@ -57,13 +71,11 @@ diag "create an IR and check that we couldn't change constituency"
     my $ticket = RT::Ticket->new( $RT::SystemUser );
     $ticket->Load( $ir_id );
     ok $ticket->id, 'loaded ticket';
-    is $ticket->QueueObj->Name, 'Incident Reports', 'correct value';
-    is $ticket->FirstCustomFieldValue('Constituency'), 'GOVNET', 'correct value';
+    is $ticket->QueueObj->Name, 'Incident Reports - GOVNET', 'correct value';
 
     # click [new] near 'incident', set another constituency and create
     $agent->follow_link_ok({text => 'New'}, "go to 'New Incident' page");
     my $form = $agent->form_number(3);
-    ok $form->find_input( $form->value('Constituency'), 'hidden'), 'constituency field is hidden';
     $agent->click('CreateIncident');
     is $agent->status, 200, "Attempted to create the ticket";
 
@@ -74,17 +86,13 @@ diag "create an IR and check that we couldn't change constituency"
     $ticket = RT::Ticket->new( $RT::SystemUser );
     $ticket->Load( $inc_id );
     ok $ticket->id, 'loaded ticket';
-    is $ticket->QueueObj->Name, 'Incidents', 'correct value';
-    is $ticket->FirstCustomFieldValue('Constituency'),
-        'GOVNET', 'correct value';
+    is $ticket->QueueObj->Name, 'Incidents - GOVNET', 'correct value';
 
     # And the report too
     $ticket = RT::Ticket->new( $RT::SystemUser );
     $ticket->Load( $ir_id );
     ok $ticket->id, 'loaded ticket';
-    is $ticket->QueueObj->Name, 'Incident Reports', 'correct value';
-    is $ticket->FirstCustomFieldValue('Constituency'),
-        'GOVNET', 'correct value';
+    is $ticket->QueueObj->Name, 'Incident Reports - GOVNET', 'correct value';
 }
 
 diag "create an incident with EDUNET, then try to create children using"
@@ -92,28 +100,25 @@ diag "create an incident with EDUNET, then try to create children using"
         if $ENV{'TEST_VERBOSE'};
 {
     my $incident_id = $agent->create_rtir_ticket_ok(
-        'Incidents',
+        'Incidents - EDUNET',
         { Subject => "test" },
-        { Constituency => 'EDUNET' },
     );
     {
         my $ticket = RT::Ticket->new( $RT::SystemUser );
         $ticket->Load( $incident_id );
         ok $ticket->id, 'loaded ticket';
-        is $ticket->FirstCustomFieldValue('Constituency'),
-            'EDUNET', 'correct value';
+        is $ticket->QueueObj->Name, 'Incidents - EDUNET',
+            'correct value';
     }
 
     foreach my $queue( 'Incident Reports', 'Investigations', 'Blocks' ) {
-        diag "create a ticket in the '$queue' queue" if $ENV{'TEST_VERBOSE'};
+        diag "create a ticket in the '$queue - GOVNET' queue" if $ENV{'TEST_VERBOSE'};
 
         my $id = $agent->create_rtir_ticket(
-            $queue,
+            $queue. ' - GOVNET',
             {
                 Subject => "test constituency",
-                Incident => $incident_id,
             },
-            { Constituency => 'GOVNET' },
         );
         ok !$id, 'ticket was not created';
         $agent->content_like(
@@ -128,28 +133,26 @@ diag "create an incident with EDUNET and check that we can create children"
         if $ENV{'TEST_VERBOSE'};
 {
     my $incident_id = $agent->create_rtir_ticket_ok(
-        'Incidents',
+        'Incidents - EDUNET',
         { Subject => "test" },
-        { Constituency => 'EDUNET' },
     );
     {
         my $ticket = RT::Ticket->new( $RT::SystemUser );
         $ticket->Load( $incident_id );
         ok $ticket->id, 'loaded ticket';
-        is $ticket->FirstCustomFieldValue('Constituency'),
-            'EDUNET', 'correct value';
+        is $ticket->QueueObj->Name ,
+            'Incidents - EDUNET', 'correct value';
     }
 
     foreach my $queue( 'Incident Reports', 'Investigations', 'Blocks' ) {
-        diag "create a ticket in the '$queue' queue" if $ENV{'TEST_VERBOSE'};
+        diag "create a ticket in the '$queue - EDUNET' queue" if $ENV{'TEST_VERBOSE'};
 
         my $id = $agent->create_rtir_ticket_ok(
-            $queue,
+            $queue . ' - EDUNET',
             {
                 Subject => "test constituency",
                 Incident => $incident_id,
             },
-            { Constituency => 'EDUNET' },
         );
 
         $agent->display_ticket( $id);
@@ -159,13 +162,13 @@ diag "create an incident with EDUNET and check that we can create children"
             my $ticket = RT::Ticket->new( $RT::SystemUser );
             $ticket->Load( $id );
             ok $ticket->id, 'loaded ticket';
-            is uc $ticket->FirstCustomFieldValue('Constituency'),
+            is uc $ticket->QueueObj->FirstCustomFieldValue('RTIR Constituency'),
                 'EDUNET', 'correct value';
         } {
             my $ticket = RT::Ticket->new( $RT::SystemUser );
             $ticket->Load( $incident_id );
             ok $ticket->id, 'loaded ticket';
-            is $ticket->FirstCustomFieldValue('Constituency'),
+            is $ticket->QueueObj->FirstCustomFieldValue('RTIR Constituency'),
                 'EDUNET', 'incident still has the same value';
         }
         $agent->ticket_is_linked_to_inc( $id, $incident_id);
@@ -177,8 +180,9 @@ diag "create an IR create an Incident with different constituency"
         if $ENV{'TEST_VERBOSE'};
 {
     # an IR
-    my $ir_id = $agent->create_ir(
-        { Subject => "test" }, { Constituency => 'GOVNET' }
+    my $ir_id = $agent->create_rtir_ticket_ok(
+        'Incident Reports - GOVNET',
+        { Subject => "test" }
     );
     $agent->display_ticket( $ir_id);
     $agent->content_like( qr/GOVNET/, "value on the page" );
@@ -186,15 +190,15 @@ diag "create an IR create an Incident with different constituency"
         my $ticket = RT::Ticket->new( $RT::SystemUser );
         $ticket->Load( $ir_id );
         ok $ticket->id, 'loaded ticket';
-        is $ticket->QueueObj->Name, 'Incident Reports', 'correct value';
-        is $ticket->FirstCustomFieldValue('Constituency'),
+        is $ticket->QueueObj->Name, 'Incident Reports - GOVNET', 'correct value';
+        is $ticket->QueueObj->FirstCustomFieldValue('RTIR Constituency'),
             'GOVNET', 'correct value';
         $ticket->Subject("incident report #$ir_id");
     }
 
     # an IR
-    my $inc_id = $agent->create_incident(
-        { Subject => "test" }, { Constituency => 'EDUNET' }
+    my $inc_id = $agent->create_rtir_ticket_ok('Incidents - EDUNET',
+        { Subject => "test" }, 
     );
     $agent->display_ticket( $inc_id);
     $agent->content_like( qr/EDUNET/, "value on the page" );
@@ -202,13 +206,13 @@ diag "create an IR create an Incident with different constituency"
         my $ticket = RT::Ticket->new( $RT::SystemUser );
         $ticket->Load( $inc_id );
         ok $ticket->id, 'loaded ticket';
-        is $ticket->QueueObj->Name, 'Incidents', 'correct value';
-        is $ticket->FirstCustomFieldValue('Constituency'),
+        is $ticket->QueueObj->Name, 'Incidents - EDUNET', 'correct value';
+        is $ticket->QueueObj->FirstCustomFieldValue('RTIR Constituency'),
             'EDUNET', 'correct value';
     }
     $agent->get_ok(
         $agent->rt_base_url ."/RTIR/Link/ToIncident/?id=$inc_id&"
-        ."Queue=Incident%20Reports&Query=id%3D$ir_id"
+        ."Lifecycle=incident_report&Query=id%3D$ir_id"
     );
     $agent->content_unlike(qr/incident report #$ir_id/, 'no IR on the page');
 }
@@ -220,9 +224,8 @@ diag "check that we can change constituency of an unlinked ticket using 'Edit' p
     # blocks are always linked to an incident
     foreach my $queue( 'Incidents', 'Incident Reports', 'Investigations' ) {
         my $id = $agent->create_rtir_ticket_ok(
-            $queue,
+            $queue .' - GOVNET',
             { Subject => "test constituency" },
-            { Constituency => 'GOVNET' },
         );
         DBIx::SearchBuilder::Record::Cachable::FlushCache();
 
@@ -230,7 +233,7 @@ diag "check that we can change constituency of an unlinked ticket using 'Edit' p
             my $ticket = RT::Ticket->new( $RT::SystemUser );
             $ticket->Load( $id );
             ok $ticket->id, 'loaded ticket';
-            is $ticket->FirstCustomFieldValue('Constituency'),
+            is $ticket->QueueObj->FirstCustomFieldValue('RTIR Constituency'),
                 'GOVNET', 'correct value';
         }
         
@@ -246,7 +249,7 @@ diag "check that we can change constituency of an unlinked ticket using 'Edit' p
             my $ticket = RT::Ticket->new( $RT::SystemUser );
             $ticket->Load( $id );
             ok $ticket->id, 'loaded ticket';
-            is uc $ticket->FirstCustomFieldValue('Constituency'),
+            is uc $ticket->QueueObj->FirstCustomFieldValue('RTIR Constituency'),
                 'EDUNET', 'correct value';
         }
     }
@@ -256,33 +259,31 @@ diag "check that we can change constituency of an unlinked ticket using 'Edit' p
     if $ENV{'TEST_VERBOSE'};
 {
     my $incident_id = $agent->create_rtir_ticket_ok(
-        'Incidents',
+        'Incidents - EDUNET',
         { Subject => "test" },
-        { Constituency => 'EDUNET' },
     );
     {
         my $ticket = RT::Ticket->new( $RT::SystemUser );
         $ticket->Load( $incident_id );
         ok $ticket->id, 'loaded ticket';
-        is $ticket->FirstCustomFieldValue('Constituency'),
+        is $ticket->QueueObj->FirstCustomFieldValue('RTIR Constituency'),
             'EDUNET', 'correct value';
     }
 
     foreach my $queue( 'Blocks', 'Incident Reports', 'Investigations' ) {
         my $id = $agent->create_rtir_ticket_ok(
-            $queue,
+            $queue." - EDUNET",
             {
                 Subject => "test constituency",
                 Incident => $incident_id,
             },
-            { Constituency => 'EDUNET' },
         );
         DBIx::SearchBuilder::Record::Cachable::FlushCache();
         {
             my $ticket = RT::Ticket->new( $RT::SystemUser );
             $ticket->Load( $id );
             ok $ticket->id, 'loaded ticket';
-            is $ticket->FirstCustomFieldValue('Constituency'),
+            is $ticket->QueueObj->FirstCustomFieldValue('RTIR Constituency'),
                 'EDUNET', 'correct value';
         }
         

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the rt-commit mailing list