[Rt-commit] rt branch 4.4/simple-search-redirect-results created. rt-4.4.5-114-gdab335590c
BPS Git Server
git at git.bestpractical.com
Thu Jun 2 20:02:30 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/simple-search-redirect-results has been created
at dab335590c283d31daf8fbe9c23744f39f9d8225 (commit)
- Log -----------------------------------------------------------------
commit dab335590c283d31daf8fbe9c23744f39f9d8225
Author: Jason Crome <jcrome at bestpractical.com>
Date: Tue May 31 17:22:41 2022 -0400
Make simple search result refresh always function
There is a circumstance in which simple search results cannot be
refreshed. Doing a simple search and selecting a refresh interval always
works, but the next simple search performed without changing the
refresh interval will produce the error "There was an error parsing your
search query..." This prevents that error from happening.
Simple search uses share/html/Search/Results.html to
display its results. When a refresh interval is selected, it is
submitted as a form parameter to /Search/Results.html, and a CSRF token
is generated for that request path. When the next simple search is
performed, the search term is submitted to /Search/Simple.html, and a
CSRF token is generated for that path. When the results auto-refresh,
however, the path /Search/Results.html is what is refreshed, and that
path doesn't match the path for the CSRF token, causing the error above.
There is nothing different about the simple search results page that
distinguishes it from the results provided by Search Builder, so rather
than compose that Mason template into Search/Simple.html, redirect to
Search/Results.html like Search Builder does currently.
diff --git a/share/html/Search/Simple.html b/share/html/Search/Simple.html
index 4490f192f2..dba4348f0c 100644
--- a/share/html/Search/Simple.html
+++ b/share/html/Search/Simple.html
@@ -115,10 +115,10 @@ if ($q) {
$m->callback( %ARGS, CallbackName => 'SearchArgs', args => \%args);
- my $search = RT::Search::Simple->new(%args);
-
- $m->comp( "Results.html", Query => $search->QueryToSQL() );
- $m->comp( "/Elements/Footer" );
+ my $search = RT::Search::Simple->new(%args);
+ my $query = $m->comp('/Elements/QueryString', %ARGS, Query => $search->QueryToSQL() );
+ my $result_path = RT->Config->Get('WebURL') . "Search/Results.html?$query";
+ RT::Interface::Web::Redirect( $result_path );
$m->abort();
}
</%INIT>
commit 63b040542ff52fc2fcf38938e05aec0236a22a89
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Jun 3 03:19:10 2022 +0800
Fix simple ticket search tests to make sure tickets are really found
Previously some tests were passed by accident as the string to find was
the value of simple search input, which was also on the page. This
commit switches to text_contains to skip input values and also check
found ticket numbers to make tests more reliable.
E.g. "fulltext:base'ticket" didn't find any tickets but related tests
passed. The reason it couldn't find any tickets is RT::Ticket doesn't
support "Content" argument, so "base'ticket" was only in Subject field,
and as a result in EmailRecord transaction too. But in "Indexed => 0"
fulltext search, EmailRecord isn't searched.
This commit switches to RT::Test::create_ticket, which supports
"Content" argument so fulltext searches can find related tickets.
diff --git a/t/web/simple_search.t b/t/web/simple_search.t
index 0a9c2c0c7f..95b8adbcaa 100644
--- a/t/web/simple_search.t
+++ b/t/web/simple_search.t
@@ -15,6 +15,7 @@ my $two_words_queue = RT::Test->load_or_create_queue(
);
ok $two_words_queue && $two_words_queue->id, 'loaded or created a queue';
+my $root = RT::Test->load_or_create_user( Name => 'root' );
{
my $tickets = RT::Tickets->new( RT->SystemUser );
@@ -68,38 +69,29 @@ ok $two_words_queue && $two_words_queue->id, 'loaded or created a queue';
is $parser->QueryToSQL(q{cf."don't foo?":'bar n\\' baz'}), qq/( 'CF.{don\\'t foo?}' LIKE 'bar n\\' baz' ) AND ( Status = '__Active__' )/, "correct parsing of CFs with quotes";
}
-my $ticket_found_1 = RT::Ticket->new($RT::SystemUser);
-my $ticket_found_2 = RT::Ticket->new($RT::SystemUser);
-my $ticket_not_found = RT::Ticket->new($RT::SystemUser);
-
-$ticket_found_1->Create(
+my $ticket_found_1 = RT::Test->create_ticket(
Subject => 'base ticket 1'.$$,
Queue => 'general',
- Owner => 'root',
+ Owner => $root->Id,
Requestor => 'customsearch at localhost',
Content => 'this is base ticket 1',
);
-ok( $ticket_found_1->id, 'created ticket for custom search');
-
-$ticket_found_2->Create(
+my $ticket_found_2 = RT::Test->create_ticket(
Subject => 'base ticket 2'.$$,
Queue => 'general',
- Owner => 'root',
+ Owner => $root->Id,
Requestor => 'customsearch at localhost',
Content => 'this is base ticket 2',
);
-ok( $ticket_found_2->id, 'created ticket for custom search');
-$ticket_not_found = RT::Ticket->new($RT::SystemUser);
-$ticket_not_found->Create(
+my $ticket_not_found = RT::Test->create_ticket(
Subject => 'not found subject' . $$,
Queue => 'other',
- Owner => 'nobody',
+ Owner => RT->Nobody->Id,
Requestor => 'notfound at localhost',
Content => 'this is not found content',
);
-ok( $ticket_not_found->id, 'created ticket for custom search');
ok($m->login, 'logged in');
@@ -114,9 +106,10 @@ 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' );
+ $m->text_contains( 'Found 2 tickets' );
+ $m->text_contains( 'base ticket 1', 'base ticket 1 is found' );
+ $m->text_contains( 'base ticket 2', 'base ticket 2 is found' );
+ $m->text_lacks( 'not found subject', 'not found ticket is not found' );
}
$ticket_not_found->SetStatus('open');
@@ -126,9 +119,10 @@ 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' );
+ $m->text_contains( 'Found 2 tickets' );
+ $m->text_contains( 'base ticket 1', 'base ticket 1 is found' );
+ $m->text_contains( 'base ticket 2', 'base ticket 2 is found' );
+ $m->text_lacks( 'not found subject', 'not found ticket is not found' );
}
@queries = ( 'fulltext:"base ticket 1"', "'base ticket 1'" );
@@ -136,9 +130,10 @@ 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_lacks( 'base ticket 2', 'base ticket 2 is not found' );
- $m->content_lacks( 'not found subject', 'not found ticket is not found' );
+ $m->text_contains( 'Found 1 ticket' );
+ $m->text_contains( 'base ticket 1', 'base ticket 1 is found' );
+ $m->text_lacks( 'base ticket 2', 'base ticket 2 is not found' );
+ $m->text_lacks( 'not found subject', 'not found ticket is not found' );
}
# now let's test with ' or "
@@ -158,17 +153,15 @@ for my $quote ( q{'}, q{"} ) {
- my $ticket_quote = RT::Ticket->new($RT::SystemUser);
- $ticket_quote->Create(
+ RT::Test->create_ticket(
Subject => qq!base${quote}ticket $$!,
Queue => 'general',
- Owner => $user->Name,
+ Owner => $user->Id,
( $quote eq q{'}
? (Requestor => qq!custom${quote}search\@localhost!)
: () ),
Content => qq!this is base${quote}ticket with quote inside!,
);
- ok( $ticket_quote->id, 'created ticket with quote for custom search' );
@queries = (
qq!fulltext:base${quote}ticket!,
@@ -188,10 +181,8 @@ for my $quote ( q{'}, q{"} ) {
$m->form_with_fields('q');
$m->field( q => $q );
$m->submit;
- my $escape_quote = $quote;
- RT::Interface::Web::EscapeHTML(\$escape_quote);
- $m->content_contains( "base${escape_quote}ticket",
- "base${quote}ticket is found" );
+ $m->text_contains( 'Found 1 ticket' );
+ $m->text_contains( "base${quote}ticket", "base${quote}ticket is found" );
}
}
@@ -213,9 +204,10 @@ for my $quote ( q{'}, q{"} ) {
$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' );
+ $m->text_contains( 'Found 2 tickets' );
+ $m->text_contains( 'base ticket 1', 'base ticket 1 is found' );
+ $m->text_contains( 'base ticket 2', 'base ticket 2 is found' );
+ $m->text_lacks( 'not found subject', 'not found ticket is not found' );
}
}
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list