[Rt-commit] rt branch, 5.0/lifecycle-ui-mappings-fixes, created. rt-5.0.0-71-gfcf4fd87ca
Craig Kaiser
craig at bestpractical.com
Wed Nov 4 13:00:01 EST 2020
The branch, 5.0/lifecycle-ui-mappings-fixes has been created
at fcf4fd87ca9541583675ff68030e8c374014d956 (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 192ee2e23f037a85a3ca92e37352f649a132da5e
Author: craig kaiser <craig at bestpractical.com>
Date: Tue Nov 3 16:41:49 2020 -0500
Add general tests for the lifecycle Mappings.html page
diff --git a/t/web/lifecycle_mappings.t b/t/web/lifecycle_mappings.t
new file mode 100644
index 0000000000..400d83f007
--- /dev/null
+++ b/t/web/lifecycle_mappings.t
@@ -0,0 +1,152 @@
+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'],
+ }
+};
+
+my ($ret, $msg) = $lifecycleObj->_SaveLifecycles(
+ $new_lifecycle,
+ RT->SystemUser,
+);
+ok $ret, "Updated lifecycle successfully";
+RT::Lifecycle->FillCache();
+
+diag "Test updating mappings from web UI";
+{
+ 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( $from, $default->MoveMap( $foo ), "Move map from default -> foo set correctly" );
+ is_deeply( $to, $foo->MoveMap( $default ), "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( $from, $default->MoveMap( $foo ), "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 ($input->value, $from->{$default_status}, "Mapping set correctly for default -> foo for status: $default_status" );
+ }
+ elsif ( $foo_from ) {
+ is ( $input->value, $to->{$foo_status}, "Mapping set correctly for foo -> default for status: $foo_to" );
+ }
+ }
+}
+
+done_testing;
commit 6654c27b437e16a3f3a65d42036f8236a6371143
Author: craig kaiser <craig at bestpractical.com>
Date: Tue Nov 3 16:43:01 2020 -0500
Add test for case variant statuses in mappings
When statuses are case sensitive the web UI can end up not displaying
the real mapping values.
diff --git a/t/web/lifecycle_mappings.t b/t/web/lifecycle_mappings.t
index 400d83f007..c6dcf83a31 100644
--- a/t/web/lifecycle_mappings.t
+++ b/t/web/lifecycle_mappings.t
@@ -13,7 +13,7 @@ my $new_lifecycle = {
foo => {
type => 'ticket',
initial => ['initial'],
- active => ['active'],
+ active => ['active', 'case-Variant-Status'],
inactive => ['inactive'],
}
};
@@ -42,7 +42,7 @@ diag "Test updating mappings from web UI";
"map-foo-inactive--default" => "resolved",
"map-default-deleted--foo" => "inactive",
"map-default-rejected--foo" => "inactive",
- "map-default-stalled--foo" => "active",
+ "map-default-stalled--foo" => "case-Variant-Status",
"Name" => "default",
"Type" => "ticket",
},
@@ -71,7 +71,7 @@ diag "Test updating mappings from web UI";
open => "active",
rejected => "inactive",
resolved => "inactive",
- stalled => "active"
+ stalled => "case-variant-status"
};
my $to = {
@@ -97,7 +97,7 @@ diag "Test updating mappings from web UI";
"map-foo-inactive--default" => "resolved",
"map-default-deleted--foo" => "inactive",
"map-default-rejected--foo" => "inactive",
- "map-default-stalled--foo" => "active",
+ "map-default-stalled--foo" => "case-variant-status",
"Name" => "default",
"Type" => "ticket",
},
@@ -126,7 +126,7 @@ diag "Confirm the web UI correctly displays mappings";
open => "active",
rejected => "inactive",
resolved => "inactive",
- stalled => "active"
+ stalled => "case-variant-status"
};
my $to = {
commit 8e0e6d18d96f0c19558cd3b3aad9e28ebe63573a
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 ecfd137760b0435b2e6b4e57d725dd4e85909b2b
Author: craig kaiser <craig at bestpractical.com>
Date: Tue Nov 3 16:59:21 2020 -0500
Move code for parsing mappings form submissions to sub routine
diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
index 7a4f6ef31b..432e967dbe 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -953,6 +953,29 @@ sub UpdateMaps {
return (1, $CurrentUser->loc("Lifecycle mappings updated"));
}
+=head2 ParseMappingsInput
+
+Parse form submission from Mappings.html lifecycle UI page to fit the
+usual lifecycle __maps__ layout.
+
+=cut
+
+sub ParseMappingsInput {
+ my $args = shift;
+
+ my @lifecycle_names = grep { $_ ne 'approvals' } RT::Lifecycle->ListAll($args->{'Type'});
+
+ my %maps;
+ my $lifecycle_re = join '|', map { quotemeta($_) } @lifecycle_names;
+ for my $key (keys %{$args}) {
+ my ($from_lifecycle, $from_status, $to_lifecycle) = $key =~ /^map-($lifecycle_re)-(.*)--($lifecycle_re)$/ or next;
+ if (my $to_status = $args->{$key}) {
+ $maps{"$from_lifecycle -> $to_lifecycle"}{$from_status} = $to_status;
+ }
+ }
+ return %maps;
+}
+
=head2 ValidateLifecycle( CurrentUser => undef, Lifecycle => undef, Name => undef )
Validate passed Lifecycle data structure.
diff --git a/share/html/Admin/Lifecycles/Mappings.html b/share/html/Admin/Lifecycles/Mappings.html
index ce18f4cc8d..8d3fe8085a 100644
--- a/share/html/Admin/Lifecycles/Mappings.html
+++ b/share/html/Admin/Lifecycles/Mappings.html
@@ -125,14 +125,7 @@ MaybeRedirectForResults(
my @lifecycle_names = grep { $_ ne 'approvals' } RT::Lifecycle->ListAll($Type);
if ($Update) {
- my %maps;
- my $lifecycle_re = join '|', map { quotemeta($_) } @lifecycle_names;
- for my $key (keys %ARGS) {
- my ($from_lifecycle, $from_status, $to_lifecycle) = $key =~ /^map-($lifecycle_re)-(.*)--($lifecycle_re)$/ or next;
- if (my $to_status = $ARGS{$key}) {
- $maps{"$from_lifecycle -> $to_lifecycle"}{$from_status} = $to_status;
- }
- }
+ my %maps = RT::Lifecycle::ParseMappingsInput( \%ARGS );
my ($ok, $msg) = RT::Lifecycle->UpdateMaps(
CurrentUser => $session{CurrentUser},
commit 9766162b861a66d3690aae174d15ebaec96f9919
Author: craig kaiser <craig at bestpractical.com>
Date: Wed Nov 4 10:02:20 2020 -0500
Add failing test for RT::Lifecycle::ParseMappingsInput
The existing parsing code will fail if a status in the mappings form has
a "-" in the name.
diff --git a/t/web/lifecycle_mappings.t b/t/web/lifecycle_mappings.t
index c6dcf83a31..62fd919b28 100644
--- a/t/web/lifecycle_mappings.t
+++ b/t/web/lifecycle_mappings.t
@@ -15,6 +15,64 @@ my $new_lifecycle = {
initial => ['initial'],
active => ['active', 'case-Variant-Status'],
inactive => ['inactive'],
+ },
+ sales => {
+ "initial" => ["sales"],
+ "active" => [
+ "engineering",
+ "stalled"
+ ],
+ "inactive" => [
+ "resolved",
+ "rejected",
+ "deleted"
+ ],
+ },
+ "sales-engineering" => {
+ "initial" => ["sales"],
+ "active" => [
+ "engineering",
+ "stalled"
+ ],
+ "inactive" => [
+ "resolved",
+ "rejected",
+ "deleted"
+ ],
+ },
+ "__maps__" => {
+ "default -> sales" => {
+ "deleted" => "deleted",
+ "new" => "sales",
+ "open" => "engineering",
+ "rejected" => "rejected",
+ "resolved" => "resolved",
+ "stalled" => "stalled"
+ },
+ "sales -> default" => {
+ "deleted" => "deleted",
+ "sales" => "new",
+ "engineering" => "open",
+ "rejected" => "rejected",
+ "resolved" => "resolved",
+ "stalled" => "stalled"
+ },
+ "default -> sales-engineering" => {
+ "deleted" => "deleted",
+ "new" => "sales",
+ "open" => "engineering",
+ "rejected" => "rejected",
+ "resolved" => "resolved",
+ "stalled" => "stalled"
+ },
+ "sales-engineering -> default" => {
+ "deleted" => "deleted",
+ "sales" => "new",
+ "engineering" => "new", # We want this to be different than the sales mapping
+ "rejected" => "rejected",
+ "resolved" => "resolved",
+ "stalled" => "stalled"
+ },
}
};
@@ -136,7 +194,7 @@ diag "Confirm the web UI correctly displays mappings";
};
my @inputs = $form->inputs;
- foreach my $input ( @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)$/;
@@ -149,4 +207,85 @@ diag "Confirm the web UI correctly displays mappings";
}
}
+diag "Test RT::Lifecycle::ParseMappingsInput method";
+{
+ my %args = (
+ "map-default-new--sales-engineering" => "sales",
+ "map-default-open--sales-engineering" => "engineering",
+ "map-default-stalled--sales-engineering" => "stalled",
+ "map-default-rejected--sales-engineering" => "rejected",
+ "map-default-resolved--sales-engineering" => "resolved",
+ "map-default-deleted--sales-engineering" => "deleted",
+
+ "map-sales-engineering-sales--default" => "new",
+ "map-sales-engineering-engineering--default" => "open",
+ "map-sales-engineering-stalled--default" => "stalled",
+ "map-sales-engineering-rejected--default" => "rejected",
+ "map-sales-engineering-resolved--default" => "resolved",
+ "map-sales-engineering-deleted--default" => "deleted",
+ );
+ my %maps = RT::Lifecycle::ParseMappingsInput( \%args );
+
+ my %expected = (
+ 'default -> sales-engineering' => {
+ "new" => "sales",
+ "open" => "engineering",
+ "rejected" => "rejected",
+ "resolved" => "resolved",
+ "stalled" => "stalled",
+ "deleted" => "deleted",
+ },
+ 'sales-engineering -> default' => {
+ "sales" => "new",
+ "engineering" => "open",
+ "rejected" => "rejected",
+ "resolved" => "resolved",
+ "stalled" => "stalled",
+ "deleted" => "deleted",
+ }
+ );
+
+ is_deeply( \%expected, \%maps, "RT::Lifecycle::ParseMappingsInput method successfully parsed input." );
+
+ RT::Test->stop_server;
+ RT->Config->LoadConfigFromDatabase();
+ ( $url, $m ) = RT::Test->started_ok;
+ ok( $m->login( 'root', 'password' ), 'logged in' );
+ $lifecycles = RT->Config->Get('Lifecycles');
+
+ my %updated_maps = (%{$lifecycles->{'__maps__'}}, %maps);
+ $lifecycles->{'__maps__'} = \%updated_maps;
+
+ ($ret, $msg) = $lifecycleObj->_SaveLifecycles(
+ $lifecycles,
+ RT->SystemUser,
+ );
+ ok $ret, "Updated lifecycle successfully";
+
+ RT::Test->stop_server;
+ RT->Config->LoadConfigFromDatabase();
+ ( $url, $m ) = RT::Test->started_ok;
+ ok( $m->login( 'root', 'password' ), 'logged in' );
+ $lifecycles = RT->Config->Get('Lifecycles');
+
+ $m->get_ok( $url . '/Admin/Lifecycles/Mappings.html?Type=ticket&Name=sales-engineering' );
+ my $form = $m->form_name('ModifyMappings');
+
+ my $to = $expected{"default -> sales-engineering"};
+ my $from = $maps{"sales-engineering -> default"};
+
+ my @inputs = $form->inputs;
+ foreach my $input ( @inputs ) {
+ my ($default_from, $default_status, $default_to) = $input->name =~ /^map-(sales-engineering)-(.*)--(default)$/;
+ my ($sales_engineering_from, $sales_engineering_status, $sales_engineering_to) = $input->name =~ /^map-(default)-(.*)--(sales-engineering)$/;
+
+ if ( $default_from ) {
+ is ($input->value, $from->{$default_status}, "Mapping set correctly for default -> sales_engineering for status: $default_status" );
+ }
+ elsif ( $sales_engineering_from ) {
+ is ( $input->value, $to->{$sales_engineering_status}, "Mapping set correctly for sales_engineering -> default for status: $sales_engineering_to" );
+ }
+ }
+}
+
done_testing;
commit 809d968670eca9c7fad64e0dac55bab87019ace8
Author: craig kaiser <craig at bestpractical.com>
Date: Tue Nov 3 17:57:51 2020 -0500
Update mapping form submission parsing to handle '-' in lifecycle name
diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
index 432e967dbe..a0f986e1ab 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -964,11 +964,13 @@ sub ParseMappingsInput {
my $args = shift;
my @lifecycle_names = grep { $_ ne 'approvals' } RT::Lifecycle->ListAll($args->{'Type'});
+ my $lifecycle_re = join '|', map { quotemeta($_) } @lifecycle_names;
my %maps;
- my $lifecycle_re = join '|', map { quotemeta($_) } @lifecycle_names;
for my $key (keys %{$args}) {
my ($from_lifecycle, $from_status, $to_lifecycle) = $key =~ /^map-($lifecycle_re)-(.*)--($lifecycle_re)$/ or next;
+ next unless $from_lifecycle && $from_status && $to_lifecycle;
+
if (my $to_status = $args->{$key}) {
$maps{"$from_lifecycle -> $to_lifecycle"}{$from_status} = $to_status;
}
commit 2b948ec25edd30395c28a93a011c2e1de62d9802
Author: craig kaiser <craig at bestpractical.com>
Date: Tue Nov 3 18:01:04 2020 -0500
Add test for when lifecycle status has '-' in name
diff --git a/t/web/lifecycle_mappings.t b/t/web/lifecycle_mappings.t
index 62fd919b28..f4c3a9c35c 100644
--- a/t/web/lifecycle_mappings.t
+++ b/t/web/lifecycle_mappings.t
@@ -32,7 +32,8 @@ my $new_lifecycle = {
"initial" => ["sales"],
"active" => [
"engineering",
- "stalled"
+ "stalled",
+ "sales-engineering"
],
"inactive" => [
"resolved",
@@ -66,12 +67,13 @@ my $new_lifecycle = {
"stalled" => "stalled"
},
"sales-engineering -> default" => {
- "deleted" => "deleted",
- "sales" => "new",
- "engineering" => "new", # We want this to be different than the sales mapping
- "rejected" => "rejected",
- "resolved" => "resolved",
- "stalled" => "stalled"
+ "sales-engineering" => "open",
+ "deleted" => "deleted",
+ "sales" => "new",
+ "engineering" => "new", # We want this to be different than the sales mapping
+ "rejected" => "rejected",
+ "resolved" => "resolved",
+ "stalled" => "stalled"
},
}
};
@@ -236,12 +238,13 @@ diag "Test RT::Lifecycle::ParseMappingsInput method";
"deleted" => "deleted",
},
'sales-engineering -> default' => {
- "sales" => "new",
- "engineering" => "open",
- "rejected" => "rejected",
- "resolved" => "resolved",
- "stalled" => "stalled",
- "deleted" => "deleted",
+ "sales-engineering" => "open",
+ "sales" => "new",
+ "engineering" => "open",
+ "rejected" => "rejected",
+ "resolved" => "resolved",
+ "stalled" => "stalled",
+ "deleted" => "deleted",
}
);
commit fde947cc2c1d9b12e3079200f5506724d6e20154
Author: craig kaiser <craig at bestpractical.com>
Date: Tue Nov 3 18:42:22 2020 -0500
Tighten up regex for lifecycle UI mappings parsing
Added additional "-" to the mapping select name so that statuses or
lifecycles with single "-" in the name will not break the regex.
diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
index a0f986e1ab..aab12ae0ba 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -968,7 +968,7 @@ sub ParseMappingsInput {
my %maps;
for my $key (keys %{$args}) {
- my ($from_lifecycle, $from_status, $to_lifecycle) = $key =~ /^map-($lifecycle_re)-(.*)--($lifecycle_re)$/ or next;
+ my ($from_lifecycle, $from_status, $to_lifecycle) = $key =~ /^map-($lifecycle_re)--(.*)--($lifecycle_re)$/;
next unless $from_lifecycle && $from_status && $to_lifecycle;
if (my $to_status = $args->{$key}) {
diff --git a/share/html/Admin/Lifecycles/Mappings.html b/share/html/Admin/Lifecycles/Mappings.html
index 8d3fe8085a..943adad613 100644
--- a/share/html/Admin/Lifecycles/Mappings.html
+++ b/share/html/Admin/Lifecycles/Mappings.html
@@ -74,7 +74,7 @@
<% $OtherStatus %>:
</div>
<div class="col-8 value">
- <& /Elements/SelectStatus, Statuses => \@MyStatuses, Default => $FromMapping->{$OtherStatus}, Name => 'map-' . $Other->Name . '-' . $OtherStatus . '--' . $LifecycleObj->Name&>
+ <& /Elements/SelectStatus, Statuses => \@MyStatuses, Default => $FromMapping->{$OtherStatus}, Name => 'map-' . $Other->Name . '--' . $OtherStatus . '--' . $LifecycleObj->Name&>
</div>
</div>
% }
@@ -88,7 +88,7 @@
<% $MyStatus %>:
</div>
<div class="col-8 value">
- <& /Elements/SelectStatus, Statuses => \@OtherStatuses, Default => $ToMapping->{$MyStatus}, Name => 'map-' . $LifecycleObj->Name . '-' . $MyStatus . '--' . $Other->Name &>
+ <& /Elements/SelectStatus, Statuses => \@OtherStatuses, Default => $ToMapping->{$MyStatus}, Name => 'map-' . $LifecycleObj->Name . '--' . $MyStatus . '--' . $Other->Name &>
</div>
</div>
% }
commit fcf4fd87ca9541583675ff68030e8c374014d956
Author: craig kaiser <craig at bestpractical.com>
Date: Tue Nov 3 18:42:36 2020 -0500
Update lifecycle mappings test for new regex
diff --git a/t/web/lifecycle_mappings.t b/t/web/lifecycle_mappings.t
index f4c3a9c35c..9b869c138b 100644
--- a/t/web/lifecycle_mappings.t
+++ b/t/web/lifecycle_mappings.t
@@ -94,17 +94,17 @@ diag "Test updating mappings from web UI";
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" => "case-Variant-Status",
- "Name" => "default",
- "Type" => "ticket",
+ "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" => "case-Variant-Status",
+ "Name" => "default",
+ "Type" => "ticket",
},
button => 'Update'
);
@@ -149,17 +149,17 @@ diag "Test updating mappings from web UI";
$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" => "case-variant-status",
- "Name" => "default",
- "Type" => "ticket",
+ "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" => "case-variant-status",
+ "Name" => "default",
+ "Type" => "ticket",
},
button => 'Update'
);
@@ -193,18 +193,19 @@ diag "Confirm the web UI correctly displays mappings";
active => "open",
inactive => "resolved",
initial => "new",
+ "case-variant-status" => ""
};
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)$/;
+ my ($default_from, $default_status, $default_to) = $input->name =~ /^map-(default)--(.*)--(foo)$/;
+ my ($foo_from, $foo_status, $foo_to) = $input->name =~ /^map-(foo)--(.*)--(default)$/;
if ( $default_from ) {
is ($input->value, $from->{$default_status}, "Mapping set correctly for default -> foo for status: $default_status" );
}
elsif ( $foo_from ) {
- is ( $input->value, $to->{$foo_status}, "Mapping set correctly for foo -> default for status: $foo_to" );
+ is ( $input->value, $to->{$foo_status}, "Mapping set correctly for foo -> default for status: $foo_status" );
}
}
}
@@ -212,19 +213,20 @@ diag "Confirm the web UI correctly displays mappings";
diag "Test RT::Lifecycle::ParseMappingsInput method";
{
my %args = (
- "map-default-new--sales-engineering" => "sales",
- "map-default-open--sales-engineering" => "engineering",
- "map-default-stalled--sales-engineering" => "stalled",
- "map-default-rejected--sales-engineering" => "rejected",
- "map-default-resolved--sales-engineering" => "resolved",
- "map-default-deleted--sales-engineering" => "deleted",
-
- "map-sales-engineering-sales--default" => "new",
- "map-sales-engineering-engineering--default" => "open",
- "map-sales-engineering-stalled--default" => "stalled",
- "map-sales-engineering-rejected--default" => "rejected",
- "map-sales-engineering-resolved--default" => "resolved",
- "map-sales-engineering-deleted--default" => "deleted",
+ "map-default--new--sales-engineering" => "sales",
+ "map-default--open--sales-engineering" => "engineering",
+ "map-default--stalled--sales-engineering" => "stalled",
+ "map-default--rejected--sales-engineering" => "rejected",
+ "map-default--resolved--sales-engineering" => "resolved",
+ "map-default--deleted--sales-engineering" => "deleted",
+
+ "map-sales-engineering--sales--default" => "new",
+ "map-sales-engineering--engineering--default" => "open",
+ "map-sales-engineering--stalled--default" => "stalled",
+ "map-sales-engineering--rejected--default" => "rejected",
+ "map-sales-engineering--resolved--default" => "resolved",
+ "map-sales-engineering--deleted--default" => "deleted",
+ "map-sales-engineering--sales-engineering--default" => "open"
);
my %maps = RT::Lifecycle::ParseMappingsInput( \%args );
@@ -279,8 +281,8 @@ diag "Test RT::Lifecycle::ParseMappingsInput method";
my @inputs = $form->inputs;
foreach my $input ( @inputs ) {
- my ($default_from, $default_status, $default_to) = $input->name =~ /^map-(sales-engineering)-(.*)--(default)$/;
- my ($sales_engineering_from, $sales_engineering_status, $sales_engineering_to) = $input->name =~ /^map-(default)-(.*)--(sales-engineering)$/;
+ my ($default_from, $default_status, $default_to) = $input->name =~ /^map-(sales-engineering)--(.*)--(default)$/;
+ my ($sales_engineering_from, $sales_engineering_status, $sales_engineering_to) = $input->name =~ /^map-(default)--(.*)--(sales-engineering)$/;
if ( $default_from ) {
is ($input->value, $from->{$default_status}, "Mapping set correctly for default -> sales_engineering for status: $default_status" );
-----------------------------------------------------------------------
More information about the rt-commit
mailing list