Bug 19564: (QA follow-up) Make commented out tests pass
authorNick Clemens <nick@bywatersolutions.com>
Wed, 28 Mar 2018 12:42:19 +0000 (12:42 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Mon, 14 May 2018 13:49:06 +0000 (13:49 +0000)
We likely shoudln't pass through an uncoverted sort order for now, but
it does allow us to look ahead to implementing the orders directly so
seems a good option to have.

Either this patch should be used, or the commented out tests should be
removed

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t

index 98a2d59..8a0ead1 100644 (file)
@@ -487,7 +487,7 @@ sub _convert_sort_fields {
         pubdate     => 'pubdate',
     );
     my %sort_order_convert =
-      ( qw( dsc desc ), qw( asc asc ), qw( az asc ), qw( za desc ) );
+      ( qw( desc desc ), qw( dsc desc ), qw( asc asc ), qw( az asc ), qw( za desc ) );
 
     # Convert the fields and orders, drop anything we don't know about.
     grep { $_->{field} } map {
index de7ef95..5085690 100644 (file)
@@ -230,7 +230,7 @@ subtest 'build_query tests' => sub {
 };
 
 subtest "_convert_sort_fields" => sub {
-    plan tests => 1;
+    plan tests => 2;
     my @sort_by = $builder->_convert_sort_fields(qw( call_number_asc author_dsc ));
     is_deeply(
         \@sort_by,
@@ -242,13 +242,13 @@ subtest "_convert_sort_fields" => sub {
     );
 
     # We could expect this to pass, but direction is undef instead of 'desc'
-    #@sort_by = $builder->_convert_sort_fields(qw( call_number_asc author_desc ));
-    #is_deeply(
-    #    \@sort_by,
-    #    [
-    #        { field => 'callnum', direction => 'asc' },
-    #        { field => 'author',  direction => 'desc' }
-    #    ],
-    #    'sort fields should have been split correctly'
-    #);
+    @sort_by = $builder->_convert_sort_fields(qw( call_number_asc author_desc ));
+    is_deeply(
+        \@sort_by,
+        [
+            { field => 'callnum', direction => 'asc' },
+            { field => 'author',  direction => 'desc' }
+        ],
+        'sort fields should have been split correctly'
+    );
 };