[Rt-commit] rt branch 5.0/article-autocomplete-should-be-case-insensitive created. rt-5.0.3-126-ge7577c3262

BPS Git Server git at git.bestpractical.com
Thu Nov 17 17:42:37 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, 5.0/article-autocomplete-should-be-case-insensitive has been created
        at  e7577c3262e670473a01a79fa810adc526b137d2 (commit)

- Log -----------------------------------------------------------------
commit e7577c3262e670473a01a79fa810adc526b137d2
Author: Brian Conry <bconry at bestpractical.com>
Date:   Thu Nov 17 10:46:40 2022 -0600

    Add case-sensitivity tests for Atircles autocomplete

diff --git a/t/web/case-sensitivity.t b/t/web/case-sensitivity.t
index 6cb0f1579a..ad45f8fcfa 100644
--- a/t/web/case-sensitivity.t
+++ b/t/web/case-sensitivity.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 18;
+use RT::Test tests => 25;
 
 my $q = RT::Test->load_or_create_queue( Name => 'General' );
 ok $q && $q->id, 'loaded or created queue';
@@ -13,6 +13,12 @@ my ($root, $root_id);
     ok $root_id = $root->id, 'found root';
 }
 
+RT->Config->Set( 'ArticleSearchFields', {
+    Name         => 'STARTSWITH',
+    Summary      => 'LIKE',
+    'CF.1'       => 'LIKE',
+});
+
 my ($baseurl, $m) = RT::Test->started_ok;
 $m->login;
 
@@ -86,3 +92,30 @@ my $cf;
     );
 }
 
+# test articles auto completer
+{
+    my $article_name = 'Case-Sensitive Sample Article ' . $$;
+    my $art = RT::Article->new($RT::SystemUser);
+    my ($id,$msg) =$art->Create(
+        Class           => 'General',
+        Name            => $article_name,
+        Description     => 'A Case-Sensitive Article Description',
+        Summary         => 'A Case-Sensitive Article Summary',
+        'CustomField-1' => 'Case-sensitive Article Content',
+    );
+    ok($id,$msg);
+
+    my $result = [{ "label" =>  $article_name, "value" => 1 }];
+
+    # test Name
+    $m->get_ok('/Helpers/Autocomplete/Articles?return=id&queue=1&term=case-sensitive sample article');
+    is_deeply( JSON::from_json( $m->content ), $result, 'Found by Name' );
+
+    # test Summary
+    $m->get_ok('/Helpers/Autocomplete/Articles?return=id&queue=1&term=article summary');
+    is_deeply( JSON::from_json( $m->content ), $result, 'Found by Summary' );
+
+    # test CF.Content
+    $m->get_ok('/Helpers/Autocomplete/Articles?return=id&queue=1&term=article content');
+    is_deeply( JSON::from_json( $m->content ), $result, 'Found by Content' );
+}

commit 15939df55c3f4bc3c91ef641a9b011d251e0254b
Author: Brian Conry <bconry at bestpractical.com>
Date:   Thu Nov 17 10:23:16 2022 -0600

    Article autocomplete should be case insensitive
    
    CHange c8274d2937 added the ability to customize the fields searched for
    autocomplete results when finding articles to include.
    
    That change also inadvertantly made those searches case sensitive.
    
    This change fixes that.

diff --git a/lib/RT/Articles.pm b/lib/RT/Articles.pm
index 285cfe6de9..db4f188ef8 100644
--- a/lib/RT/Articles.pm
+++ b/lib/RT/Articles.pm
@@ -927,6 +927,7 @@ sub SimpleSearch {
                 LookupType => RT::Article->new( $self->CurrentUser )->CustomFieldLookupType,
             );
             if ( $ok ) {
+                # LimitCustomField already adds CASESENSITIVE => 0
                 $self->LimitCustomField(
                     CUSTOMFIELD     => $cf->Id,
                     OPERATOR        => $op,
@@ -944,6 +945,7 @@ sub SimpleSearch {
                 VALUE           => $args{Term},
                 ENTRYAGGREGATOR => 'OR',
                 SUBCLAUSE       => 'autocomplete',
+                CASESENSITIVE   => 0,
             );
         }
     }

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list