Bugzilla – Attachment 154275 Details for
Bug 27378
Enable compliance with EU Cookie Legislation via cookie consent
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27378: (QA follow-up) Fix tests and character encoding
Bug-27378-QA-follow-up-Fix-tests-and-character-enc.patch (text/plain), 7.65 KB, created by
Katrin Fischer
on 2023-08-04 13:09:24 UTC
(
hide
)
Description:
Bug 27378: (QA follow-up) Fix tests and character encoding
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2023-08-04 13:09:24 UTC
Size:
7.65 KB
patch
obsolete
>From ea2e0b403ba66700a3e9a00cef8069ed7faa6e5a Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Mon, 31 Jul 2023 13:37:33 +0000 >Subject: [PATCH] Bug 27378: (QA follow-up) Fix tests and character encoding > >This patch fixes an encoding issue when using diacritics. It also fixes a failing test, corrects the format of the "Cancel" links in the modal and perltidy has been used on all relevant files > >Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> >--- > Koha/Template/Plugin/JSConsents.pm | 4 ++- > .../bug_27378-add_cookie_consents.pl | 14 ++++++---- > .../prog/en/includes/intranet-bottom.inc | 2 +- > .../bootstrap/en/includes/masthead.inc | 2 +- > .../Koha/Template/Plugin/JSConsents.t | 28 ++++++++++++++++--- > 5 files changed, 38 insertions(+), 12 deletions(-) > >diff --git a/Koha/Template/Plugin/JSConsents.pm b/Koha/Template/Plugin/JSConsents.pm >index 2148cc12c3..174a36a02e 100644 >--- a/Koha/Template/Plugin/JSConsents.pm >+++ b/Koha/Template/Plugin/JSConsents.pm >@@ -21,6 +21,7 @@ use Template::Plugin; > use base qw( Template::Plugin ); > use MIME::Base64 qw{ decode_base64 }; > use JSON qw{ decode_json }; >+use Encode qw{ encode_utf8 }; > > use C4::Context; > >@@ -30,7 +31,8 @@ sub all { > my $consents = C4::Context->preference('CookieConsentedJS'); > if ( length $consents > 0 ) { > my $decoded_consents = decode_base64($consents); >- my $consents_array = decode_json $decoded_consents; >+ my $convert_to_utf8 = encode_utf8($decoded_consents); >+ my $consents_array = decode_json $convert_to_utf8; > my @filtered_consents = grep { $_->{$filter} } @{$consents_array}; > return \@filtered_consents; > } else { >diff --git a/installer/data/mysql/atomicupdate/bug_27378-add_cookie_consents.pl b/installer/data/mysql/atomicupdate/bug_27378-add_cookie_consents.pl >index ca2205f35e..40f2904985 100644 >--- a/installer/data/mysql/atomicupdate/bug_27378-add_cookie_consents.pl >+++ b/installer/data/mysql/atomicupdate/bug_27378-add_cookie_consents.pl >@@ -1,16 +1,20 @@ > use Modern::Perl; > > return { >- bug_number => "27378", >+ bug_number => "27378", > description => "Adds the sysprefs for cookie consents", >- up => sub { >+ up => sub { > my ($args) = @_; >- my ($dbh, $out) = @$args{qw(dbh out)}; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; > >- $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('CookieConsentedJS', '', 'Add Javascript code that will run if cookie consent is provided (e.g. tracking code).', '', 'Free'); | ); >+ $dbh->do( >+ q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('CookieConsentedJS', '', 'Add Javascript code that will run if cookie consent is provided (e.g. tracking code).', '', 'Free'); | >+ ); > say $out "Added new system preference 'CookieConsentedJS'"; > >- $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('CookieConsent', '0', 'Require cookie consent to be displayed', '', 'YesNo'); | ); >+ $dbh->do( >+ q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('CookieConsent', '0', 'Require cookie consent to be displayed', '', 'YesNo'); | >+ ); > say $out "Added new system preference 'CookieConsent'"; > }, > }; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc >index cd3abdfb5a..f46b55d01e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc >@@ -137,7 +137,7 @@ > <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button> > <button type="button" class="btn btn-success" id="consentAcceptSelected">Accept selected non-essential cookies</button> > [% END %] >- <button type="button" class="btn btn-secondary consentCloseModal">Cancel</button> >+ <a type="button" href="#" class="btn btn-secondary consentCloseModal">Cancel</a> > </div> > </div> > </div> <!-- /.modal-content --> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >index 8788bf9520..b33ad52477 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >@@ -503,7 +503,7 @@ > <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button> > <button type="button" class="btn btn-warning" id="consentAcceptSelected">Accept selected non-essential cookies</button> > [% END %] >- <button type="button" class="btn btn-secondary consentCloseModal">Cancel</button> >+ <a type="button" href="#" class="btn btn-secondary consentCloseModal">Cancel</a> > </div> > </div> > </div> <!-- /.modal-content --> >diff --git a/t/db_dependent/Koha/Template/Plugin/JSConsents.t b/t/db_dependent/Koha/Template/Plugin/JSConsents.t >index e48f359651..27428f0bbe 100755 >--- a/t/db_dependent/Koha/Template/Plugin/JSConsents.t >+++ b/t/db_dependent/Koha/Template/Plugin/JSConsents.t >@@ -9,7 +9,7 @@ use Test::More tests => 3; > use t::lib::Mocks; > > BEGIN { >- use_ok('Koha::Template::Plugin::JSConsents', "Can use Koha::Template::Plugin::JSConsents"); >+ use_ok( 'Koha::Template::Plugin::JSConsents', "Can use Koha::Template::Plugin::JSConsents" ); > } > > ok( my $consents = Koha::Template::Plugin::JSConsents->new(), 'Able to instantiate template plugin' ); >@@ -17,9 +17,29 @@ ok( my $consents = Koha::Template::Plugin::JSConsents->new(), 'Able to instantia > subtest "all" => sub { > plan tests => 1; > >- t::lib::Mocks::mock_preference( 'CookieConsentedJS', 'eyAidGVzdCI6ICJvbmUiIH0=' ); >- >- is_deeply( $consents->all(), { test => 'one' }, 'Returns a Base64 decoded JSON object converted into a data structure'); >+ t::lib::Mocks::mock_preference( >+ 'CookieConsentedJS', >+ 'W3siaWQiOiJfbGFrZGhjOW11IiwibmFtZSI6InRlc3QiLCJkZXNjcmlwdGlvbiI6InRlc3QiLCJtYXRjaFBhdHRlcm4iOiJ0ZXN0MSIsImNvb2tpZURvbWFpbiI6ImxvY2FsaG9zdCIsImNvb2tpZVBhdGgiOiIvIiwib3BhY0NvbnNlbnQiOnRydWUsInN0YWZmQ29uc2VudCI6dHJ1ZSwiY29kZSI6IktHWjFibU4wYVc5dUtDa2dleUFLSUNBZ0lHTnZibk52YkdVdWJHOW5LQ2RJWld4c2J5Qm1jbTl0SUhSbGMzUXhKeWs3SUFvZ0lDQWdaRzlqZFcxbGJuUXVZMjl2YTJsbElEMGdJblJsYzNReFBYUmxjM1JwYm1jN0lHUnZiV0ZwYmoxc2IyTmhiR2h2YzNRN0lIQmhkR2c5THpzZ1UyRnRaVk5wZEdVOVRtOXVaVHNnVTJWamRYSmxJanNnQ24wcEtDazcifV0=' >+ ); >+ >+ is_deeply( >+ $consents->all('opacConsent'), >+ [ >+ { >+ 'name' => 'test', >+ 'cookiePath' => '/', >+ 'code' => >+ 'KGZ1bmN0aW9uKCkgeyAKICAgIGNvbnNvbGUubG9nKCdIZWxsbyBmcm9tIHRlc3QxJyk7IAogICAgZG9jdW1lbnQuY29va2llID0gInRlc3QxPXRlc3Rpbmc7IGRvbWFpbj1sb2NhbGhvc3Q7IHBhdGg9LzsgU2FtZVNpdGU9Tm9uZTsgU2VjdXJlIjsgCn0pKCk7', >+ 'staffConsent' => 1, >+ 'matchPattern' => 'test1', >+ 'description' => 'test', >+ 'cookieDomain' => 'localhost', >+ 'opacConsent' => 1, >+ 'id' => '_lakdhc9mu' >+ } >+ ], >+ 'Returns a Base64 decoded JSON object converted into a data structure' >+ ); > }; > > 1; >-- >2.30.2
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 27378
:
115544
|
115545
|
115546
|
115547
|
115548
|
115756
|
116397
|
116398
|
116399
|
116400
|
116401
|
116402
|
116403
|
116416
|
116417
|
116418
|
116419
|
116420
|
116421
|
116422
|
116423
|
116978
|
116979
|
116980
|
116981
|
116982
|
116983
|
116984
|
116985
|
116986
|
121728
|
121729
|
121730
|
121731
|
121732
|
121733
|
121734
|
121735
|
121995
|
121996
|
121997
|
121998
|
121999
|
122000
|
122001
|
122002
|
122635
|
122636
|
122637
|
122638
|
122639
|
122640
|
122641
|
122642
|
124957
|
124958
|
124959
|
124960
|
124961
|
124962
|
124963
|
124964
|
124965
|
130072
|
130073
|
130074
|
130075
|
130076
|
130077
|
130078
|
130079
|
130080
|
135309
|
135310
|
135311
|
135312
|
135313
|
135314
|
135315
|
135316
|
135317
|
135318
|
151735
|
151736
|
151737
|
151738
|
151739
|
151740
|
151741
|
151742
|
151743
|
151744
|
151745
|
151746
|
151747
|
151748
|
151749
|
151750
|
151751
|
151752
|
151753
|
151826
|
151827
|
151828
|
151829
|
151830
|
151831
|
151832
|
151833
|
151834
|
151835
|
151836
|
151837
|
151838
|
151839
|
151840
|
151841
|
151842
|
151843
|
151844
|
153326
|
153327
|
153328
|
153329
|
153330
|
153331
|
153332
|
153333
|
153334
|
153335
|
153336
|
154015
|
154016
|
154017
|
154018
|
154019
|
154020
|
154021
|
154022
|
154023
|
154024
|
154025
|
154093
|
154264
|
154265
|
154266
|
154267
|
154268
|
154269
|
154270
|
154271
|
154272
|
154273
|
154274
| 154275 |
154276