[Rt-commit] [rtir] 01/03: Failing tests for splitting a Report.

Kevin Falcone falcone at bestpractical.com
Fri Jun 21 17:54:00 EDT 2013


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

falcone pushed a commit to branch 2.9/split-multiple-incidents
in repository rtir.

commit c163ca8fe77dee3d4d7f3258be67c0a8fa30a56e
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Fri Jun 21 14:21:09 2013 -0400

    Failing tests for splitting a Report.
    
    The same failures occur on Blocks, but they share the code.
    Previously, RTIR would hardcode the lowest Incident ID into the Split
    page and then use that one.  With the change to letting you choose which
    Incident you want applied (both, all 3, one, a different one?) it
    uncovered a bug that RTIR had even more code hardcoding of which
    incident to link to.
    
    This code tests that you can apply the split Report to both incidents,
    can choose the second incident and can choose a third different
    incident.
    
    oops
---
 t/report/split.t | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 109 insertions(+)

diff --git a/t/report/split.t b/t/report/split.t
new file mode 100644
index 0000000..18c32b4
--- /dev/null
+++ b/t/report/split.t
@@ -0,0 +1,109 @@
+use strict;
+use warnings;
+
+use RT::IR::Test tests => undef;
+
+RT::Test->started_ok;
+my $m = default_agent();
+
+my %viewed = ( '/NoAuth/Logout.html' => 1 );    # in case logout
+
+my $first_incident  = $m->create_incident({ Subject => "test Incident" });
+my $second_incident = $m->create_incident({ Subject => "other test Incident" }); 
+
+# the built-in create_incident_report doesn't support linking to multiple incidents
+# despite this being added as an explicit feature in 2.4.0. I'm assuming
+# it's never actually been tested before. This code wants to be cleaned
+# up and shove into RT::IR::Test::Web but it's kind of ugly.
+my $ir = create_incident_report({Subject => "test Report", Incidents => [$first_incident,$second_incident]});
+
+my $extra_incident = $m->create_incident({ Subject => "further test Incident" }); 
+
+{ diag("Keep both Incident parents - the default");
+    $m->display_ticket($ir);
+    $m->follow_link_ok({text => "Split"}, "Followed link");
+    $m->form_number(3);
+
+    is_deeply([grep $_, $m->current_form->param('Incident')],[$first_incident,$second_incident],"Both Incidents are Checked");
+    $m->click_ok('Create',"Split the Report");
+
+    my $new_ir = $m->get_ticket_id;
+    my $report = load_ticket($new_ir);
+
+    my $new_incidents = RT::IR->Incidents($report);
+    is($new_incidents->Count,2);
+    is_deeply([sort map { $_->Id } @{$new_incidents->ItemsArrayRef}],[$first_incident,$second_incident],"Properly linked to the second incident");
+}
+
+{ diag("Splitting the report and keeping the second Incident");
+    $m->display_ticket($ir);
+    $m->follow_link_ok({text => "Split"}, "Followed link");
+    $m->form_number(3);
+
+    is_deeply([grep $_, $m->current_form->param('Incident')],[$first_incident,$second_incident],"Both Incidents are Checked");
+    $m->untick('Incident',1);
+    $m->click_ok('Create',"Split the Report");
+
+    my $new_ir = $m->get_ticket_id;
+    my $report = load_ticket($new_ir);
+
+    my $new_incidents = RT::IR->Incidents($report);
+    is($new_incidents->Count,1);
+    is($new_incidents->First->Id,$second_incident,"Properly linked to the second incident");
+}
+
+{ diag("Splitting the report and applying it to a third unrelated incident");
+    $m->display_ticket($ir);
+    $m->follow_link_ok({text => "Split"}, "Followed link");
+    $m->form_number(3);
+
+    is_deeply([grep $_, $m->current_form->param('Incident')],[$first_incident,$second_incident],"Both Incidents are Checked");
+    $m->untick('Incident',1);
+    $m->untick('Incident',2);
+    $m->field('Incident',$extra_incident,3);
+    $m->click_ok('Create',"Split the Report");
+
+    my $new_ir = $m->get_ticket_id;
+    my $report = load_ticket($new_ir);
+
+    my $new_incidents = RT::IR->Incidents($report);
+    is($new_incidents->Count,1);
+    is($new_incidents->First->Id,$extra_incident,"Properly linked to the third incident");
+}
+
+
+sub load_ticket {
+    my $id = shift;
+    my $ticket = RT::Ticket->new(RT->SystemUser);
+    $ticket->Load($id);
+    is($ticket->Id,$id,"Loaded IR $id");
+    return $ticket;
+}
+
+sub create_incident_report {
+    my $args = shift;
+    my $incidents = delete $args->{Incidents};
+    $m->goto_create_rtir_ticket('Incident Reports');
+
+    # because the Other Incident and the checkboxes are all named
+    # Incident, we have to indicate which field named Incident we want.
+    my $count = 1;
+    for my $incident (@$incidents) {
+        $m->save_content("ir.html");
+        $m->field('Incident',$incident,$count++);
+        $m->click_ok('MoreIncident',"Add incident $incident to the IR");
+        $m->form_number(3);
+    }
+
+    while (my ($f, $v) = each %$args) {
+        $m->field($f, $v);
+    }
+    $m->click('Create');
+
+    my $ir = $m->get_ticket_id;
+    my $report = load_ticket($ir);
+    is(RT::IR->IsLinkedToActiveIncidents($report),scalar @$incidents,"Created an IR linked to ".scalar @$incidents." Incidents");
+    return $ir;
+}
+
+done_testing;

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


More information about the Rt-commit mailing list