[Rt-commit] rt branch, 5.0/lifecycle-ui-mappings-fixes, created. rt-5.0.0-64-gda656f2ef8

Craig Kaiser craig at bestpractical.com
Tue Nov 3 08:26:53 EST 2020


The branch, 5.0/lifecycle-ui-mappings-fixes has been created
        at  da656f2ef88d590d9a3f359346ba6ca278798818 (commit)

- Log -----------------------------------------------------------------
commit ef08c6395d1e7d60f1ad4de92f4a5c69fa36d0fb
Author: craig kaiser <craig at bestpractical.com>
Date:   Fri Oct 30 16:07:53 2020 -0400

    Update instructions for lifecycle mapping page to mention assets

diff --git a/share/html/Admin/Lifecycles/Mappings.html b/share/html/Admin/Lifecycles/Mappings.html
index 0da577941b..ce18f4cc8d 100644
--- a/share/html/Admin/Lifecycles/Mappings.html
+++ b/share/html/Admin/Lifecycles/Mappings.html
@@ -50,7 +50,7 @@
 <& /Elements/ListActions, actions => \@results &>
 <div class="form-row">
   <div class="col-12">
-    <p><&|/l&>If a ticket is moved from one queue or catalog to another, these mappings define how statuses should be updated.</&></p>
+    <p><&|/l&>If a ticket or asset is moved from one queue or catalog to another, these mappings define how statuses should be updated.</&></p>
   </div>
 </div>
 

commit db0a5a029ee894d0e47a5a2353b063f753eca88d
Author: craig kaiser <craig at bestpractical.com>
Date:   Fri Oct 30 16:06:09 2020 -0400

    Return lower case statuses from RT::Lifecycle->Valid
    
    Per:
    
    15857be24af0955e5eeb46e6bab96378704e1e09
    
    Statuses are stored in lower-case, in order for the 'Valid' method to be
    used to compare statuses with the results of other methods such as
    RT::Lifecycle->MoveMap the values returned must also be lower-case.

diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
index 7f39bd7d97..7a4f6ef31b 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -242,11 +242,11 @@ sub Valid {
     my $self = shift;
     my @types = @_;
     unless ( @types ) {
-        return @{ $self->{'data'}{''} || [] };
+        return map { lc $_ } @{ $self->{'data'}{''} || [] };
     }
 
     my @res;
-    push @res, @{ $self->{'data'}{ $_ } || [] } foreach @types;
+    push @res, map { lc $_ } @{ $self->{'data'}{ $_ } || [] } foreach @types;
     return @res;
 }
 

commit da656f2ef88d590d9a3f359346ba6ca278798818
Author: craig kaiser <craig at bestpractical.com>
Date:   Tue Nov 3 08:07:02 2020 -0500

    Add tests for lifecycle UI mappings page

diff --git a/t/web/lifecycle_mappings.t b/t/web/lifecycle_mappings.t
new file mode 100644
index 0000000000..3ddb07d3ca
--- /dev/null
+++ b/t/web/lifecycle_mappings.t
@@ -0,0 +1,160 @@
+use strict;
+use warnings;
+
+use RT::Test tests => undef;
+
+my ( $url, $m ) = RT::Test->started_ok;
+
+my $lifecycleObj = RT::Lifecycle->new();
+my $lifecycles   = RT->Config->Get('Lifecycles');
+
+my $new_lifecycle = {
+      %{$lifecycles},
+      foo => {
+          type     => 'ticket',
+          initial  => ['initial'],
+          active   => ['active'],
+          inactive => ['inactive'],
+          actions  => [],
+          transitions => {
+            '' => [
+                "initial",
+                "active",
+                "inactive"
+            ],
+          }
+      }
+};
+
+my ($ret, $msg) = $lifecycleObj->_SaveLifecycles(
+    $new_lifecycle,
+    RT->SystemUser,
+);
+ok $ret, "Updated lifecycle successfully";
+RT::Lifecycle->FillCache();
+
+diag "Test updating mappings";
+{
+    ok( $m->login( 'root', 'password' ), 'logged in' );
+
+    $m->get_ok( $url . '/Admin/Lifecycles/Mappings.html?Type=ticket&Name=default' );
+
+    my $form = $m->form_name('ModifyMappings');
+    $m->submit_form(
+      fields => {
+        "map-default-new--foo"      => "initial",
+        "map-default-open--foo"     => "active",
+        "map-default-resolved--foo" => "inactive",
+        "map-foo-initial--default"  => "new",
+        "map-foo-active--default"   => "open",
+        "map-foo-inactive--default" => "resolved",
+        "map-default-deleted--foo"  => "inactive",
+        "map-default-rejected--foo" => "inactive",
+        "map-default-stalled--foo"  => "active",
+        "Name"                      => "default",
+        "Type"                      => "ticket",
+      },
+      button => 'Update'
+    );
+    $m->content_contains( 'Lifecycle mappings updated' );
+
+    RT::Test->stop_server;
+    RT->Config->LoadConfigFromDatabase();
+    ( $url, $m ) = RT::Test->started_ok;
+    ok( $m->login( 'root', 'password' ), 'logged in' );
+
+    RT::Lifecycle->FillCache();
+
+    my $foo = RT::Lifecycle->new();
+    ($ret, $msg) = $foo->Load( Name => 'foo', Type => 'ticket' );
+    ok $ret, "Loaded lifecycle foo successfully";
+
+    my $default = RT::Lifecycle->new();
+    ($ret, $msg) = $default->Load( Name => 'default', Type => 'ticket' );
+    ok $ret, "Loaded lifecycle default successfully";
+
+    my $from = {
+        deleted    => "inactive",
+        new        => "initial",
+        open       => "active",
+        rejected   => "inactive",
+        resolved   => "inactive",
+        stalled    => "active"
+    };
+
+    my $to = {
+        active     => "open",
+        inactive   => "resolved",
+        initial    => "new"
+    };
+
+    is_deeply( $default->MoveMap( $foo ), $from, "Move map from default -> foo set correctly" );
+    is_deeply( $foo->MoveMap( $default ), $to, "Move map from foo -> default set correctly" );
+
+    $from->{'new'} = 'active';
+
+    $m->get_ok( $url . '/Admin/Lifecycles/Mappings.html?Type=ticket&Name=default' );
+    $form = $m->form_name('ModifyMappings');
+    $m->submit_form(
+      fields => {
+        "map-default-new--foo"      => "active",
+        "map-default-open--foo"     => "active",
+        "map-default-resolved--foo" => "inactive",
+        "map-foo-initial--default"  => "new",
+        "map-foo-active--default"   => "open",
+        "map-foo-inactive--default" => "resolved",
+        "map-default-deleted--foo"  => "inactive",
+        "map-default-rejected--foo" => "inactive",
+        "map-default-stalled--foo"  => "active",
+        "Name"                      => "default",
+        "Type"                      => "ticket",
+      },
+      button => 'Update'
+    );
+    $m->content_contains( 'Lifecycle mappings updated' );
+
+    RT::Test->stop_server;
+    RT->Config->LoadConfigFromDatabase();
+    ( $url, $m ) = RT::Test->started_ok;
+    RT::Lifecycle->FillCache();
+
+    is_deeply( $default->MoveMap( $foo ), $from, "Move map from default -> foo updated correctly" );
+}
+
+diag "Confirm the web UI correctly displays mappings";
+{
+    ok( $m->login( 'root', 'password' ), 'logged in' );
+
+    $m->get_ok( $url . '/Admin/Lifecycles/Mappings.html?Type=ticket&Name=default' );
+    my $form = $m->form_name('ModifyMappings');
+
+     my $from = {
+        deleted    => "inactive",
+        new        => "active",
+        open       => "active",
+        rejected   => "inactive",
+        resolved   => "inactive",
+        stalled    => "active"
+    };
+
+    my $to = {
+        active     => "open",
+        inactive   => "resolved",
+        initial    => "new"
+    };
+
+    my @inputs = $form->inputs;
+    foreach my $input ( @inputs) {
+        my ($default_from, $default_status, $default_to) = $input->name =~ /^map-(default)-(.*)--(foo)$/;
+        my ($foo_from, $foo_status, $foo_to) = $input->name =~ /^map-(default)-(.*)--(foo)$/;
+
+        if ( $default_from ) {
+            is ( $from->{$default_status}, $input->value, "Mapping set correctly for default -> foo for status: $default_status" );
+        }
+        elsif ( $foo_from ) {
+            is ( $to->{$foo_status}, $input->value, "Mapping set correctly for foo -> default for status: $foo_to" );
+        }
+    }
+}
+
+done_testing;

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


More information about the rt-commit mailing list