[Rt-commit] rt branch, 4.0/cfs-in-simple-search, created. rt-4.0.1-129-g9173f45

Thomas Sibley trs at bestpractical.com
Wed Jul 27 12:43:49 EDT 2011


The branch, 4.0/cfs-in-simple-search has been created
        at  9173f453901cc079b90bc9796a1ef0b69363ff84 (commit)

- Log -----------------------------------------------------------------
commit abb70d9f01f121a00c0aecdf662c3d70e765ba71
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed Jul 27 12:04:12 2011 -0400

    This test file tests the simple googleish search, not the queue list we call quicksearch

diff --git a/t/ticket/quicksearch.t b/t/ticket/googleish_search.t
similarity index 100%
rename from t/ticket/quicksearch.t
rename to t/ticket/googleish_search.t

commit 6e9d8af5ff21681adbc80cb32d333139f3650dfa
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed Jul 27 12:31:47 2011 -0400

    Failing tests for CF.Name:value syntax in the googleish search
    
    Currently Googleish produces invalid TicketSQL when handling CFs.

diff --git a/t/web/googleish_search.t b/t/web/googleish_search.t
index 2e786be..e2a4e91 100644
--- a/t/web/googleish_search.t
+++ b/t/web/googleish_search.t
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 86, config => 'Set( %FullTextSearch, Enable => 1, Indexed => 0 );';
+use RT::Test tests => 96, config => 'Set( %FullTextSearch, Enable => 1, Indexed => 0 );';
 my ($baseurl, $m) = RT::Test->started_ok;
 my $url = $m->rt_base_url;
 
@@ -63,6 +63,9 @@ ok $two_words_queue && $two_words_queue->id, 'loaded or created a queue';
     is $parser->QueryToSQL("status:active"), $active, "Explicit active search";
     is $parser->QueryToSQL("status:'active'"), "( Status = 'active' )", "Quoting active makes it the actual word";
     is $parser->QueryToSQL("inactive me"), "( Owner.id = '__CurrentUser__' ) AND $inactive", "correct parsing";
+
+    is $parser->QueryToSQL("cf.Foo:bar"), "( 'CF.{Foo}' LIKE 'bar' ) AND $active", "correct parsing of CFs";
+    is $parser->QueryToSQL(q{cf."don't foo?":'bar n\\' baz'}), qq/( 'CF.{don\\'t foo?}' LIKE 'bar n\\' baz' ) AND $active/, "correct parsing of CFs with quotes";
 }
 
 my $ticket_found_1 = RT::Ticket->new($RT::SystemUser);
@@ -189,3 +192,28 @@ for my $quote ( q{'}, q{"} ) {
             "base${quote}ticket is found" );
     }
 }
+
+# Create a CF
+{
+    my $cf = RT::CustomField->new(RT->SystemUser);
+    ok( $cf->Create(Name => 'Foo', Type => 'Freeform', MaxValues => '1', Queue => 0) );
+    ok $cf->Id;
+
+    $ticket_found_1->AddCustomFieldValue( Field => 'Foo', Value => 'bar' );
+    $ticket_found_2->AddCustomFieldValue( Field => 'Foo', Value => 'bar' );
+    $ticket_not_found->AddCustomFieldValue( Field => 'Foo', Value => 'baz' );
+    is( $ticket_found_1->FirstCustomFieldValue('Foo'), 'bar', 'cf value is ok' );
+    is( $ticket_found_2->FirstCustomFieldValue('Foo'), 'bar', 'cf value is ok' );
+    is( $ticket_not_found->FirstCustomFieldValue('Foo'), 'baz', 'cf value is ok' );
+
+    @queries = qw/cf.Foo:bar/;
+    for my $q (@queries) {
+        $m->form_with_fields('q');
+        $m->field( q => $q );
+        $m->submit;
+        $m->content_contains( 'base ticket 1', 'base ticket 1 is found' );
+        $m->content_contains( 'base ticket 2', 'base ticket 2 is found' );
+        $m->content_lacks( 'not found subject', 'not found ticket is not found' );
+    }
+}
+

commit 9173f453901cc079b90bc9796a1ef0b69363ff84
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed Jul 27 12:32:32 2011 -0400

    Identify custom fields in TicketSQL with 'CF.{Name}' not CF.'Name'

diff --git a/lib/RT/Search/Googleish.pm b/lib/RT/Search/Googleish.pm
index 009d6f4..694ec01 100644
--- a/lib/RT/Search/Googleish.pm
+++ b/lib/RT/Search/Googleish.pm
@@ -246,7 +246,7 @@ sub HandleWatcher     {
 sub HandleRequestor { return requestor => "Requestor STARTSWITH '$_[1]'";  }
 sub HandleQueue     { return queue     => "Queue = '$_[1]'";      }
 sub HandleQ         { return queue     => "Queue = '$_[1]'";      }
-sub HandleCf        { return "cf.$_[3]" => "CF.'$_[3]' LIKE '$_[1]'"; }
+sub HandleCf        { return "cf.$_[3]" => "'CF.{$_[3]}' LIKE '$_[1]'"; }
 
 RT::Base->_ImportOverlays();
 

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


More information about the Rt-commit mailing list