Bugzilla – Attachment 81472 Details for
Bug 21299
Move referer code from changelanguage to module in opac and staff
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21299: (QA follow-up) Rename module and subroutine
Bug-21299-QA-follow-up-Rename-module-and-subroutin.patch (text/plain), 6.93 KB, created by
Martin Renvoize (ashimema)
on 2018-10-29 10:23:35 UTC
(
hide
)
Description:
Bug 21299: (QA follow-up) Rename module and subroutine
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2018-10-29 10:23:35 UTC
Size:
6.93 KB
patch
obsolete
>From fe7792e049d2c7ec9df0f26f45ea5191256d0b3b Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 13 Sep 2018 08:41:10 +0200 >Subject: [PATCH] Bug 21299: (QA follow-up) Rename module and subroutine > >See QA request at comment7. >Removing camelcase from subroutinename. >Renaming module to Koha::Util::Navigation (after cmty feedback). > >Test plan: >Run t/Koha/Util/Navigation.t. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/{Util.pm => Util/Navigation.pm} | 12 +++++----- > changelanguage.pl | 4 ++-- > opac/opac-changelanguage.pl | 4 ++-- > t/Koha/Util/{localReferer.t => Navigation.t} | 24 ++++++++++---------- > 4 files changed, 22 insertions(+), 22 deletions(-) > rename Koha/{Util.pm => Util/Navigation.pm} (88%) > rename t/Koha/Util/{localReferer.t => Navigation.t} (57%) > >diff --git a/Koha/Util.pm b/Koha/Util/Navigation.pm >similarity index 88% >rename from Koha/Util.pm >rename to Koha/Util/Navigation.pm >index ce618635d3..57b0d9dfae 100644 >--- a/Koha/Util.pm >+++ b/Koha/Util/Navigation.pm >@@ -1,4 +1,4 @@ >-package Koha::Util; >+package Koha::Util::Navigation; > > # Copyright Rijksmuseum 2018 > # >@@ -26,9 +26,9 @@ Koha::Util > > =head1 SYNOPSIS > >- use Koha::Util; >+ use Koha::Util::Navigation; > my $cgi = CGI->new; >- my $referer = Koha::Util::localReferer($cgi); >+ my $referer = Koha::Util::Navigation::local_referer($cgi); > > =head1 DESCRIPTION > >@@ -36,9 +36,9 @@ Utility class > > =head1 FUNCTIONS > >-=head2 localReferer >+=head2 local_referer > >- my $referer = Koha::Util::localReferer( $cgi, { fallback => '/', remove_language => 1, staff => 1 }); >+ my $referer = Koha::Util::Navigation::local_referer( $cgi, { fallback => '/', remove_language => 1, staff => 1 }); > > If the referer is a local URI, return local path. > Otherwise return fallback. >@@ -47,7 +47,7 @@ Utility class > > =cut > >-sub localReferer { >+sub local_referer { > my ( $cgi, $params ) = @_; > my $referer = $cgi->referer; > my $fallback = $params->{fallback} // '/'; >diff --git a/changelanguage.pl b/changelanguage.pl >index c7a5c9493e..6fd31132ac 100755 >--- a/changelanguage.pl >+++ b/changelanguage.pl >@@ -18,10 +18,10 @@ > use Modern::Perl; > use CGI qw ( -utf8 ); > use C4::Templates; >-use Koha::Util; >+use Koha::Util::Navigation; > > my $query = new CGI; > my $language = $query->param('language'); >-my $url = Koha::Util::localReferer($query, {remove_language => 1, staff => 1}); >+my $url = Koha::Util::Navigation::local_referer($query, {remove_language => 1, staff => 1}); > > C4::Templates::setlanguagecookie( $query, $language, $url ); >diff --git a/opac/opac-changelanguage.pl b/opac/opac-changelanguage.pl >index 2c01b287cc..895bc80c4d 100755 >--- a/opac/opac-changelanguage.pl >+++ b/opac/opac-changelanguage.pl >@@ -18,10 +18,10 @@ > use Modern::Perl; > use CGI qw ( -utf8 ); > use C4::Templates; >-use Koha::Util; >+use Koha::Util::Navigation; > > my $query = new CGI; > my $language = $query->param('language'); >-my $url = Koha::Util::localReferer($query, { remove_language => 1 }); >+my $url = Koha::Util::Navigation::local_referer($query, { remove_language => 1 }); > > C4::Templates::setlanguagecookie( $query, $language, $url ); >diff --git a/t/Koha/Util/localReferer.t b/t/Koha/Util/Navigation.t >similarity index 57% >rename from t/Koha/Util/localReferer.t >rename to t/Koha/Util/Navigation.t >index a1d860dea4..466f296e60 100644 >--- a/t/Koha/Util/localReferer.t >+++ b/t/Koha/Util/Navigation.t >@@ -4,9 +4,9 @@ use Test::More tests => 1; > use Test::MockObject; > > use t::lib::Mocks; >-use Koha::Util; >+use Koha::Util::Navigation; > >-subtest 'Tests for localReferer' => sub { >+subtest 'Tests for local_referer' => sub { > plan tests => 10; > > my ( $referer, $base ); >@@ -17,31 +17,31 @@ subtest 'Tests for localReferer' => sub { > # Start with filled OPACBaseIRL > t::lib::Mocks::mock_preference('OPACBaseURL', 'https://koha.nl' ); > $referer = 'https://somewhere.com/myscript'; >- is( Koha::Util::localReferer($cgi), '/', 'External referer' ); >+ is( Koha::Util::Navigation::local_referer($cgi), '/', 'External referer' ); > > my $search = '/cgi-bin/koha/opac-search.pl?q=perl'; > $referer = "https://koha.nl$search"; >- is( Koha::Util::localReferer($cgi), $search, 'opac-search' ); >+ is( Koha::Util::Navigation::local_referer($cgi), $search, 'opac-search' ); > > $referer = 'https://koha.nl/custom/stuff'; >- is( Koha::Util::localReferer($cgi), '/', 'custom url' ); >+ is( Koha::Util::Navigation::local_referer($cgi), '/', 'custom url' ); > > # trailing backslash > t::lib::Mocks::mock_preference('OPACBaseURL', 'http://koha.nl/' ); > $referer = "http://koha.nl$search"; >- is( Koha::Util::localReferer($cgi), $search, 'opac-search, trailing backslash' ); >+ is( Koha::Util::Navigation::local_referer($cgi), $search, 'opac-search, trailing backslash' ); > > # no OPACBaseURL > t::lib::Mocks::mock_preference('OPACBaseURL', ''); > $referer = 'https://somewhere.com/myscript'; > $base = 'http://koha.nl'; >- is( Koha::Util::localReferer($cgi), '/', 'no opacbaseurl, external' ); >+ is( Koha::Util::Navigation::local_referer($cgi), '/', 'no opacbaseurl, external' ); > > $referer = "https://koha.nl$search"; > $base = 'https://koha.nl'; >- is( Koha::Util::localReferer($cgi), $search, 'no opacbaseurl, opac-search' ); >+ is( Koha::Util::Navigation::local_referer($cgi), $search, 'no opacbaseurl, opac-search' ); > $base = 'http://koha.nl'; >- is( Koha::Util::localReferer($cgi), $search, 'no opacbaseurl, opac-search, protocol diff' ); >+ is( Koha::Util::Navigation::local_referer($cgi), $search, 'no opacbaseurl, opac-search, protocol diff' ); > > # base contains https, referer http (this should be very unusual) > # test parameters remove_language. staff >@@ -49,12 +49,12 @@ subtest 'Tests for localReferer' => sub { > $search = '/cgi-bin/koha/catalogue/search.pl?q=perl'; # staff > $referer = "http://koha.nl:8080$search&language=zz-ZZ&debug=1"; > $base = 'https://koha.nl:8080'; >- is( Koha::Util::localReferer($cgi, { remove_language => 1, staff => 1 }), $search.'&debug=1', 'no baseurl, staff search, protocol diff (base https)' ); >+ is( Koha::Util::Navigation::local_referer($cgi, { remove_language => 1, staff => 1 }), $search.'&debug=1', 'no baseurl, staff search, protocol diff (base https)' ); > > # custom script, test fallback parameter > $referer = 'https://koha.nl/custom/stuff'; > $base = 'https://koha.nl'; >- is( Koha::Util::localReferer($cgi, { fallback => 'ZZZ' }), 'ZZZ', 'no opacbaseurl, custom url, test fallback' ); >+ is( Koha::Util::Navigation::local_referer($cgi, { fallback => 'ZZZ' }), 'ZZZ', 'no opacbaseurl, custom url, test fallback' ); > $base = 'http://koha.nl'; >- is( Koha::Util::localReferer($cgi), '/', 'no opacbaseurl, custom url, protocol diff' ); >+ is( Koha::Util::Navigation::local_referer($cgi), '/', 'no opacbaseurl, custom url, protocol diff' ); > }; >-- >2.19.1
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 21299
:
78324
|
78325
|
78334
|
78335
|
78618
|
81120
|
81121
|
81122
|
81470
|
81471
| 81472