Bug 41237: (QA follow-up): Utilize available logged in user object
Instead of re-fetching the patron object. This also adjusts tests: prove t/db_dependent/Koha/ILL/Requests.t Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
This commit is contained in:
parent
d6ce5833b7
commit
a19a6cf1ef
|
|
@ -1074,13 +1074,12 @@ pass it $params, as it does not yet have any other data associated with it.
|
|||
=cut
|
||||
|
||||
sub backend_create {
|
||||
my ( $self, $params ) = @_;
|
||||
my ( $self, $params, $loggedin_patron ) = @_;
|
||||
|
||||
# Establish whether we need to do a generic copyright clearance.
|
||||
if ( $params->{opac} ) {
|
||||
|
||||
my $patron = $params->{cardnumber} ? Koha::Patrons->find( { cardnumber => $params->{cardnumber} } ) : undef;
|
||||
my $patron_branchcode = $patron ? $patron->branchcode : undef;
|
||||
my $patron_branchcode = $loggedin_patron ? $loggedin_patron->branchcode : undef;
|
||||
my $copyright_content = Koha::AdditionalContents->search_for_display(
|
||||
{
|
||||
category => 'html_customizations',
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ if ( $op eq 'list' ) {
|
|||
$params->{cardnumber} = $patron->cardnumber if $patron;
|
||||
$params->{opac} = 1;
|
||||
$params->{lang} = C4::Languages::getlanguage($query);
|
||||
my $backend_result = $request->backend_create($params);
|
||||
my $backend_result = $request->backend_create( $params, $patron );
|
||||
|
||||
if ( $backend_result->{stage} eq 'copyrightclearance' ) {
|
||||
$template->param(
|
||||
|
|
|
|||
|
|
@ -1055,24 +1055,23 @@ subtest 'Backend core methods' => sub {
|
|||
is( $copyright_content->count, 1 );
|
||||
|
||||
$backend_create_result =
|
||||
$illrq->backend_create(
|
||||
{ opac => 1, branchcode => $illrq->patron->branchcode, cardnumber => $illrq->patron->cardnumber } );
|
||||
$illrq->backend_create( { opac => 1, branchcode => $illrq->patron->branchcode }, $illrq->patron );
|
||||
is(
|
||||
$backend_create_result->{stage}, 'copyrightclearance',
|
||||
'Additional contents found for provided cardnumber\'s library, should be copyrightclearance stage'
|
||||
'Additional contents found for logged in user\'s library, should be copyrightclearance stage'
|
||||
);
|
||||
|
||||
$backend_create_result = $illrq->backend_create( { opac => 1, branchcode => $illrq->patron->branchcode } );
|
||||
is(
|
||||
$backend_create_result->{stage}, 'commit',
|
||||
'Cardnumber not supplied and couldnt find additional_contents for all libraries. Dont show copyrightclearance'
|
||||
'Logged in patron not supplied and could not find additional_contents for all libraries. Dont show copyrightclearance'
|
||||
);
|
||||
|
||||
my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } );
|
||||
$backend_create_result = $illrq->backend_create( { opac => 1, branchcode => $patron_1->branchcode } );
|
||||
is(
|
||||
$backend_create_result->{stage}, 'commit',
|
||||
'Supplied cardnumber\'s branchcode doesnt match any additional_contents of same branchcode. Dont show copyrightclearance'
|
||||
'Logged in user\'s branchcode does not match any additional_contents of same branchcode. Dont show copyrightclearance'
|
||||
);
|
||||
|
||||
my $all_libraries_copyright_content = Koha::AdditionalContents->search_for_display(
|
||||
|
|
@ -1109,7 +1108,7 @@ subtest 'Backend core methods' => sub {
|
|||
$backend_create_result = $illrq->backend_create( { opac => 1, branchcode => $illrq->patron->branchcode } );
|
||||
is(
|
||||
$backend_create_result->{stage}, 'copyrightclearance',
|
||||
'Cardnumber not supplied, found additional_contents for all libraries. Should show copyrightclearance'
|
||||
'Logged in user not supplied, found additional_contents for all libraries. Should show copyrightclearance'
|
||||
);
|
||||
|
||||
$all_libraries_copyright_content = Koha::AdditionalContents->search_for_display(
|
||||
|
|
|
|||
Loading…
Reference in New Issue