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

BPS Git Server git at git.bestpractical.com
Thu Nov 17 18:49:15 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  6e6a294cc044ceb1157984dc5fb2a831b9d9e4b3 (commit)

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

    Add case-sensitivity tests for Articles autocomplete

diff --git a/t/web/case-sensitivity.t b/t/web/case-sensitivity.t
index 6cb0f1579a..1989d52dc5 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 => undef;
 
 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,33 @@ 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%20sample%20article');
+    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' );
+}
+
+done_testing();
+

commit 6c8afd7f49fa8658c7b28d3556d65566d6edb51c
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 inadvertently 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