From 73f515793a55ac6d2824ebad7069bb9fbbefec82 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 12 Feb 2018 17:33:18 -0300 Subject: [PATCH] Bug 18403: rename Koha::Patron->can to has_permission I do not exactly why but there is a conflict in the name of the method prove t/db_dependent/api/v1/patrons.t failed with [Mon Feb 12 17:13:16 2018] [error] Can't use string ("TO_JSON") as a HASH ref while "strict refs" in use at /home/vagrant/kohaclone/C4/Auth.pm line 2053. --- Koha/Patron.pm | 6 +++--- t/db_dependent/api/v1/patrons.t | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index c1951a5b3c..b017d43006 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -736,7 +736,7 @@ sub can_see_patrons_from { my $can = 0; if ( $self->branchcode eq $branchcode ) { $can = 1; - } elsif ( $self->can( { borrowers => 'view_borrower_infos_from_any_libraries' } ) ) { + } elsif ( $self->has_permission( { borrowers => 'view_borrower_infos_from_any_libraries' } ) ) { $can = 1; } elsif ( my $library_groups = $self->library->library_groups ) { while ( my $library_group = $library_groups->next ) { @@ -773,7 +773,7 @@ sub libraries_where_can_see_patrons { } else { unless ( - $self->can( + $self->has_permission( { borrowers => 'view_borrower_infos_from_any_libraries' } ) ) @@ -798,7 +798,7 @@ sub libraries_where_can_see_patrons { return sort (@restricted_branchcodes); } -sub can { +sub has_permission { my ( $self, $flagsrequired ) = @_; return unless $self->userid; # TODO code from haspermission needs to be moved here! diff --git a/t/db_dependent/api/v1/patrons.t b/t/db_dependent/api/v1/patrons.t index a8579db581..2166547da3 100644 --- a/t/db_dependent/api/v1/patrons.t +++ b/t/db_dependent/api/v1/patrons.t @@ -90,7 +90,7 @@ $tx = $t->ua->build_tx(GET => "/api/v1/patrons/" . ($borrower->{ borrowernumber $tx->req->cookies({name => 'CGISESSID', value => $session->id}); $t->request_ok($tx) ->status_is(403) - ->json_is('/required_permissions', {"borrowers" => "1"}); + ->json_is('/required_permissions', {"borrowers" => "edit_borrowers"}); # User without permissions, but is the owner of the object $tx = $t->ua->build_tx(GET => "/api/v1/patrons/" . $borrower->{borrowernumber}); -- 2.11.0