[Rt-commit] rt branch 4.4/fix-queue-txn-cf-default-values created. rt-4.4.5-23-gf8b48edc38

BPS Git Server git at git.bestpractical.com
Fri Jan 28 14:54:58 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 4.4/fix-queue-txn-cf-default-values has been created
        at  f8b48edc385554b9cea559b234d4c1252491bb0f (commit)

- Log -----------------------------------------------------------------
commit f8b48edc385554b9cea559b234d4c1252491bb0f
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Jan 28 22:30:43 2022 +0800

    Test queue default values page

diff --git a/t/web/admin_queue_default_values.t b/t/web/admin_queue_default_values.t
new file mode 100644
index 0000000000..0f5dfac6a9
--- /dev/null
+++ b/t/web/admin_queue_default_values.t
@@ -0,0 +1,65 @@
+use strict;
+use warnings;
+
+use RT::Test tests => undef;
+
+my ( $url, $m ) = RT::Test->started_ok;
+ok( $m->login(), 'logged in' );
+
+my $cf = RT::Test->load_or_create_custom_field(
+    Name       => 'Notes',
+    LookupType => RT::Ticket->CustomFieldLookupType,
+    Type       => 'FreeformSingle',
+    Queue      => 0,
+);
+my $txn_cf = RT::Test->load_or_create_custom_field(
+    Name       => 'Actor',
+    LookupType => RT::Transaction->CustomFieldLookupType,
+    Type       => 'FreeformSingle',
+    ObjectId   => 0,
+);
+my ( $ret, $msg ) = $txn_cf->AddToObject( RT::Queue->new( RT->SystemUser ) );
+ok( $ret, 'Added txn cf Actor globally' );
+
+my %default_values = (
+    InitialPriority                                                       => 50,
+    FinalPriority                                                         => 100,
+    Starts                                                                => '2022-02-01 12:00:00',
+    Due                                                                   => '2022-02-14 12:00:00',
+    RT::Interface::Web::GetCustomFieldInputName( CustomField => $cf )     => 'default notes',
+    RT::Interface::Web::GetCustomFieldInputName( CustomField => $txn_cf ) => 'default actor',
+);
+
+$m->get_ok( $url . '/Admin/Queues/DefaultValues.html?id=1' );
+$m->submit_form_ok(
+    {
+        form_name => 'ModifyDefaultValues',
+        fields    => \%default_values,
+        button    => 'Update',
+    }
+);
+
+for my $msg (
+    'Default value of InitialPriority changed from (no value) to 50',
+    'Default value of FinalPriority changed from (no value) to 100',
+    'Default value of Starts changed from (no value) to 2022-02-01 12:00:00',
+    'Default value of Due changed from (no value) to 2022-02-14 12:00:00',
+    'Default values changed from (no value) to default notes',
+    'Default values changed from (no value) to default actor',
+    )
+{
+    $m->text_contains($msg);
+}
+
+my $form = $m->form_name('ModifyDefaultValues');
+for my $field ( sort keys %default_values ) {
+    is( $form->find_input($field)->value, $default_values{$field}, "$field value on default values page" );
+}
+
+$m->goto_create_ticket(1);
+$form = $m->form_name('TicketCreate');
+for my $field ( sort keys %default_values ) {
+    is( $form->find_input($field)->value, $default_values{$field}, "$field value on create page" );
+}
+
+done_testing;

commit 5c26fb6ac0c56094d72cc94ea5118dc93da78f96
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Jan 28 21:40:53 2022 +0800

    Fix the bug that transaction cfs can not be saved on queue default values page
    
    The issue was introduced by cfacf290d0, which updated all custom field
    input names but failed to process transaction custom field updates.

diff --git a/share/html/Admin/Queues/DefaultValues.html b/share/html/Admin/Queues/DefaultValues.html
index c22fc62f68..8272a2e3ee 100644
--- a/share/html/Admin/Queues/DefaultValues.html
+++ b/share/html/Admin/Queues/DefaultValues.html
@@ -156,23 +156,28 @@ elsif ( $ARGS{Update} ) {
         );
         push @results, $msg;
     }
-    my $cfs = _ParseObjectCustomFieldArgs(\%ARGS)->{'RT::Ticket'}{0};
-    for my $cf_id (keys %$cfs) {
-        # In the case of inconsistent CFV submission,
-        # we'll get the 1st grouping in the hash, alphabetically
-        my ($ret, $grouping_name) = _ValidateConsistentCustomFieldValues($cf_id, $cfs->{$cf_id});
+    for my $cfs (
+        scalar _ParseObjectCustomFieldArgs( \%ARGS )->{'RT::Ticket'}{0},
+        scalar _ParseObjectCustomFieldArgs( \%ARGS )->{'RT::Transaction'}{0}
+        )
+    {
+        for my $cf_id ( keys %$cfs ) {
+            # In the case of inconsistent CFV submission,
+            # we'll get the 1st grouping in the hash, alphabetically
+            my ( $ret, $grouping_name ) = _ValidateConsistentCustomFieldValues( $cf_id, $cfs->{$cf_id} );
 
-        my $grouping = $cfs->{$cf_id}{$grouping_name};
-        my $value = $grouping->{Value} // $grouping->{Values};
+            my $grouping = $cfs->{$cf_id}{$grouping_name};
+            my $value    = $grouping->{Value} // $grouping->{Values};
 
-        my $cf = RT::CustomField->new($session{CurrentUser});
-        $cf->Load($cf_id);
-        if ( $cf->id && $cf->SupportDefaultValues ) {
-            my ($ret, $msg) = $cf->SetDefaultValues(
-                Object => $queue,
-                Values => $value,
-            );
-            push @results, $msg;
+            my $cf = RT::CustomField->new( $session{CurrentUser} );
+            $cf->Load($cf_id);
+            if ( $cf->id && $cf->SupportDefaultValues ) {
+                my ( $ret, $msg ) = $cf->SetDefaultValues(
+                    Object => $queue,
+                    Values => $value,
+                );
+                push @results, $msg;
+            }
         }
     }
 }

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list