[Rt-commit] rt branch, 5.0/lifecycle-ui-mappings-fixes, repushed
Craig Kaiser
craig at bestpractical.com
Thu Nov 12 16:48:46 EST 2020
The branch 5.0/lifecycle-ui-mappings-fixes was deleted and repushed:
was fcf4fd87ca9541583675ff68030e8c374014d956
now 5a71e1150ba43fe247f09c22df04bdbc617d9aee
1: ef08c6395d = 1: 6e2f8685dd Update instructions for lifecycle mapping page to mention assets
2: 192ee2e23f ! 2: df4ec62c0f Add general tests for the lifecycle Mappings.html page
@@ -18,13 +18,13 @@
+my $lifecycles = RT->Config->Get('Lifecycles');
+
+my $new_lifecycle = {
-+ %{$lifecycles},
-+ foo => {
-+ type => 'ticket',
-+ initial => ['initial'],
-+ active => ['active'],
-+ inactive => ['inactive'],
-+ }
++ %{$lifecycles},
++ foo => {
++ type => 'ticket',
++ initial => ['initial'],
++ active => ['active'],
++ inactive => ['inactive'],
++ }
+};
+
+my ($ret, $msg) = $lifecycleObj->_SaveLifecycles(
@@ -34,7 +34,7 @@
+ok $ret, "Updated lifecycle successfully";
+RT::Lifecycle->FillCache();
+
-+diag "Test updating mappings from web UI";
++diag "Test updating mappings";
+{
+ ok( $m->login( 'root', 'password' ), 'logged in' );
+
@@ -42,20 +42,20 @@
+
+ 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'
++ 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' );
+
@@ -97,20 +97,20 @@
+ $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'
++ 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' );
+
@@ -129,7 +129,7 @@
+ $m->get_ok( $url . '/Admin/Lifecycles/Mappings.html?Type=ticket&Name=default' );
+ my $form = $m->form_name('ModifyMappings');
+
-+ my $from = {
++ my $from = {
+ deleted => "inactive",
+ new => "active",
+ open => "active",
@@ -145,7 +145,7 @@
+ };
+
+ 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)$/;
+
3: 6654c27b43 < --: ------- Add test for case variant statuses in mappings
--: ------- > 3: 845a3c8ed5 Add test for case variant statuses in mappings
4: 8e0e6d18d9 = 4: 4d90179ee5 Return lower case statuses from RT::Lifecycle->Valid
5: ecfd137760 ! 5: 7adce3ad94 Move code for parsing mappings form submissions to sub routine
@@ -23,9 +23,9 @@
+
+ my %maps;
+ my $lifecycle_re = join '|', map { quotemeta($_) } @lifecycle_names;
-+ for my $key (keys %{$args}) {
++ 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}) {
++ if ( my $to_status = $args->{$key} ) {
+ $maps{"$from_lifecycle -> $to_lifecycle"}{$from_status} = $to_status;
+ }
+ }
--: ------- > 6: dd54d55914 Add tests for RT::Lifecycle::ParseMappingsInput
9: fde947cc2c ! 7: d4fe5e7afc Update mapping form submission parsing to handle '-' in lifecycle name
@@ -1,22 +1,19 @@
Author: craig kaiser <craig at bestpractical.com>
- 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.
+ Update mapping form submission parsing to handle '-' in lifecycle name
diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@
-
my %maps;
- for my $key (keys %{$args}) {
+ 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;
-+ 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}) {
++ 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;
+ }
diff --git a/share/html/Admin/Lifecycles/Mappings.html b/share/html/Admin/Lifecycles/Mappings.html
--- a/share/html/Admin/Lifecycles/Mappings.html
6: 9766162b86 ! 8: 4390158735 Add test for when lifecycle status has '-' in name
@@ -1,92 +1,52 @@
Author: craig kaiser <craig at bestpractical.com>
- 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.
+ Add test for when lifecycle status has '-' in name
diff --git a/t/web/lifecycle_mappings.t b/t/web/lifecycle_mappings.t
--- a/t/web/lifecycle_mappings.t
+++ b/t/web/lifecycle_mappings.t
@@
- 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"
-+ },
+ initial => ['initial'],
+ active => ['active', 'case-Variant-Status'],
+ inactive => ['inactive'],
++ },
++ "sales-engineering" => {
++ "initial" => ["sales"],
++ "active" => [
++ "engineering",
++ "stalled"
++ ],
++ "inactive" => [
++ "resolved",
++ "rejected",
++ "deleted"
++ ],
++ },
++ "__maps__" => {
++ "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"
-+ },
- }
++ "deleted" => "deleted",
++ "sales" => "new",
++ "engineering" => "new", # We want this to be different than the sales mapping
++ "rejected" => "rejected",
++ "resolved" => "resolved",
++ "stalled" => "stalled"
++ },
+ }
};
-
-@@
- };
-
- 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)$/;
@@
}
}
-+diag "Test RT::Lifecycle::ParseMappingsInput method";
++diag "Test RT::Lifecycle::ParseMappingsInput method with lifecycle that has a '-' in the name";
+{
+ my %args = (
+ "map-default-new--sales-engineering" => "sales",
@@ -106,22 +66,22 @@
+ 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",
-+ }
++ '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." );
@@ -147,7 +107,7 @@
+ 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' );
++ $m->get_ok( $url . '/Admin/Lifecycles/Mappings.html?Type=ticket&Name=foo' );
+ my $form = $m->form_name('ModifyMappings');
+
+ my $to = $expected{"default -> sales-engineering"};
7: 809d968670 < --: ------- Update mapping form submission parsing to handle '-' in lifecycle name
8: 2b948ec25e < --: ------- Add test for when lifecycle status has '-' in name
10: fcf4fd87ca < --: ------- Update lifecycle mappings test for new regex
--: ------- > 9: 5a71e1150b Update lifecycle mapping tests to pass form regex update
More information about the rt-commit
mailing list