Bug 25765: (QA follow-up) Save a DB hit
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 21 Jul 2020 14:58:02 +0000 (15:58 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 23 Jul 2020 09:17:27 +0000 (11:17 +0200)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

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

Koha/Template/Plugin/Branches.pm
t/db_dependent/Template/Plugin/Branches.t

index 51a2df9..05932da 100644 (file)
@@ -43,8 +43,7 @@ sub GetLoggedInBranchcode {
 sub GetLoggedInBranchname {
     my ($self) = @_;
 
-    my $code = $self->GetLoggedInBranchcode;
-    return $code ? $self->GetName($code) : q{};
+    return C4::Context->userenv ? C4::Context->userenv->{'branchname'} : q{};
 }
 
 sub GetURL {
index 17a41b7..f6141d9 100644 (file)
@@ -71,7 +71,7 @@ subtest 'all() tests' => sub {
     is($plugin->GetLoggedInBranchcode(), '', 'no active library code if there is no active user session');
     is($plugin->GetLoggedInBranchname(), '', 'no active library name if there is no active user session');
 
-    t::lib::Mocks::mock_userenv({ branchcode => 'MYLIBRARY' });
+    t::lib::Mocks::mock_userenv({ branchcode => 'MYLIBRARY', branchname => 'My sweet library' });
     is($plugin->GetLoggedInBranchcode(), 'MYLIBRARY', 'GetLoggedInBranchcode() returns active library code');
     is($plugin->GetLoggedInBranchname(), 'My sweet library', 'GetLoggedInBranchname() returns active library name');