Bugzilla – Attachment 112456 Details for
Bug 19482
Elasticsearch - prevent removal / editing of required indexes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19482: (follow-up) Fix update, add tests, restore closing </td>
Bug-19482-follow-up-Fix-update-add-tests-restore-c.patch (text/plain), 6.01 KB, created by
Nick Clemens (kidclamp)
on 2020-10-25 02:19:44 UTC
(
hide
)
Description:
Bug 19482: (follow-up) Fix update, add tests, restore closing </td>
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-10-25 02:19:44 UTC
Size:
6.01 KB
patch
obsolete
>From 34456bb8107a9cc9a5ea73f0dcbdd5f56da08853 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Sun, 25 Oct 2020 02:16:42 +0000 >Subject: [PATCH] Bug 19482: (follow-up) Fix update, add tests, restore closing > </td> > >To test: >1 - View the mappings page, confirm table is correctly structured >2 - prove -v t/db_dependent/Koha/SearchEngine/Elasticsearch/ExportConfig.t t/db_dependent/Koha/SearchEngine/Elasticsearch/Reset.t t/db_dependent/Koha/SearchField.t >3 - Confirm update statement works and table is ordered correctly >--- > .../atomicupdate/bug_19482_add_mandatory_field_to_mapping.perl | 2 +- > .../prog/en/modules/admin/searchengine/elasticsearch/mappings.tt | 2 +- > t/db_dependent/Koha/SearchEngine/Elasticsearch/ExportConfig.t | 4 +++- > t/db_dependent/Koha/SearchEngine/Elasticsearch/Reset.t | 6 +++++- > t/db_dependent/Koha/SearchField.t | 9 ++++++++- > 5 files changed, 18 insertions(+), 5 deletions(-) > >diff --git a/installer/data/mysql/atomicupdate/bug_19482_add_mandatory_field_to_mapping.perl b/installer/data/mysql/atomicupdate/bug_19482_add_mandatory_field_to_mapping.perl >index 2bda6ddd1f..4fb8e51274 100644 >--- a/installer/data/mysql/atomicupdate/bug_19482_add_mandatory_field_to_mapping.perl >+++ b/installer/data/mysql/atomicupdate/bug_19482_add_mandatory_field_to_mapping.perl >@@ -2,7 +2,7 @@ $DBversion = 'XXX'; # will be replaced by the RM > if( CheckVersion( $DBversion ) ) { > > if( !column_exists( 'search_field', 'mandatory' ) ) { >- $dbh->do( "ALTER TABLE search_field ADD COLUMN mandatory tinyint(1) NULL DEFAULT NULL" ); >+ $dbh->do( "ALTER TABLE search_field ADD COLUMN mandatory tinyint(1) NULL DEFAULT NULL AFTER opac" ); > } > > SetVersion( $DBversion ); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt >index 8eb5b9675b..bd726dacca 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt >@@ -197,7 +197,7 @@ a.add, a.delete { > [% ELSE %] > <input type="text" name="search_field_label" value="[% search_field.label | html %]" /> > [% END %] >- >+ </td> > <td> > [% IF search_field.mandatory %] > <input type="hidden" name="search_field_type" value="[% search_field.type | html %]" /> >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/ExportConfig.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/ExportConfig.t >index 82dc5537f6..1c5ce67649 100755 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/ExportConfig.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/ExportConfig.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 18; >+use Test::More tests => 19; > > use Koha::Database; > use Koha::SearchFields; >@@ -43,6 +43,7 @@ my $search_field = Koha::SearchFields->find_or_create( > weight => 17, > staff_client => 0, > opac => 1, >+ mandatory => 1 > }, > { key => 'name' } ); > >@@ -95,6 +96,7 @@ is( $mappings->{biblios}{title}{label}, 'Title', 'title has label Title'); > is( $mappings->{biblios}{title}{facet_order}, undef, 'Facet order is undef'); > is( $mappings->{biblios}{title}{opac}, 1, 'title is opac searchable'); > is( $mappings->{biblios}{title}{staff_client}, 0, 'title is not staff searchable'); >+is( $mappings->{biblios}{title}{mandatory}, 1, 'title is mandatory'); > > is(scalar(@{ $mappings->{biblios}{title}{mappings} }), 3, 'Title has 3 mappings'); > >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/Reset.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/Reset.t >index e57ee16596..57f4e06ea4 100755 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/Reset.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/Reset.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 5; >+use Test::More tests => 7; > use Test::MockModule; > > use Koha::Database; >@@ -29,6 +29,7 @@ my $indexes = { > 'label' => 'Match', > 'type' => '', > 'weight' => 15, >+ 'mandatory' => 0, > 'mappings' => [] > } > }, >@@ -37,6 +38,7 @@ my $indexes = { > 'label' => 'title', > 'type' => '', > 'weight' => 20, >+ 'mandatory' => 1, > 'mapping' => [] > } > } >@@ -66,9 +68,11 @@ is($search_fields->count, 2, 'There is 2 search fields after reset'); > > my $match_sf = Koha::SearchFields->search({ name => 'Match' })->next; > is($match_sf->weight, '15.00', 'Match search field is weighted with 15'); >+is($match_sf->mandatory, '0', 'Match search field is not mandatory'); > > my $title_sf = Koha::SearchFields->search({ name => 'title' })->next; > is($title_sf->weight, '20.00', 'Title search field is weighted with 20'); >+is($title_sf->mandatory, '1', 'Title search field is mandatory'); > > $schema->storage->txn_rollback; > >diff --git a/t/db_dependent/Koha/SearchField.t b/t/db_dependent/Koha/SearchField.t >index 6f426fd1b9..8212d18064 100755 >--- a/t/db_dependent/Koha/SearchField.t >+++ b/t/db_dependent/Koha/SearchField.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 8; >+use Test::More tests => 10; > > use Koha::Database; > use Koha::SearchFields; >@@ -128,11 +128,18 @@ ok($search_field->is_mapped_biblios, 'Search field is mapped with authorities an > > my $sf3 = $builder->build({ > source => 'SearchField', >+ value => { >+ mandatory => 1, >+ } > }); > > $search_field = Koha::SearchFields->find($sf3->{id}); > ok(!$search_field->is_mapped_biblios, 'Search field is not mapped'); > >+ok($search_field->mandatory, 'Search field can be marked mandatory'); >+$search_field->mandatory(0)->store; >+ok(!$search_field->mandatory, 'Search field can be marked not mandatory'); >+ > Koha::SearchFields->search({})->delete; > > $schema->storage->txn_rollback; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19482
:
68246
|
68247
|
68248
|
69250
|
72846
|
72847
|
72848
|
72878
|
72879
|
72880
|
77007
|
77008
|
77009
|
77010
|
80817
|
80818
|
80819
|
80820
|
93366
|
93367
|
93368
|
93371
|
93372
|
93373
|
97226
|
97227
|
97228
|
101312
|
101313
|
101314
|
108467
|
108468
|
108469
|
108470
|
108471
|
111923
|
111924
|
111925
|
111926
|
111927
|
111929
|
112456
|
112459
|
112460
|
112461
|
112462
|
112463
|
112464
|
112465