Bug 35030: Add 'article' to patron activity triggers
This patch adds 'article' to the list of triggers available for tracking patron activity. Test plan 1) Select 'Placing an article request TrackPatronLastActivityTriggers system preference 2) As a staff member, place a hold on any item for a test user 3) Confirm that the borrowers.lastseen field is updated for that test borrower Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
795c60e577
commit
21315eb8dc
|
|
@ -64,6 +64,7 @@ sub request {
|
|||
if $debit;
|
||||
|
||||
$self->store();
|
||||
$self->patron->update_lastseen('article');
|
||||
$self->notify();
|
||||
return $self;
|
||||
}
|
||||
|
|
@ -226,6 +227,19 @@ sub borrower {
|
|||
return Koha::Patron->_new_from_dbic($rs);
|
||||
}
|
||||
|
||||
=head3 patron
|
||||
|
||||
Returns the Koha::Patron object for this article request
|
||||
|
||||
=cut
|
||||
|
||||
sub patron {
|
||||
my ($self) = @_;
|
||||
my $rs = $self->_result->borrowernumber;
|
||||
return unless $rs;
|
||||
return Koha::Patron->_new_from_dbic($rs);
|
||||
}
|
||||
|
||||
=head3 branch
|
||||
|
||||
Returns the Koha::Library object for this article request
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ Patrons:
|
|||
renewal: "Renewing an item"
|
||||
check_in: "Returning an item"
|
||||
hold: "Placing a hold on an item"
|
||||
article: "Places an article request"
|
||||
-
|
||||
- pref: AutoApprovePatronProfileSettings
|
||||
choices:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ my $builder = t::lib::TestBuilder->new;
|
|||
|
||||
subtest 'request() tests' => sub {
|
||||
|
||||
plan tests => 11;
|
||||
plan tests => 13;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ subtest 'request() tests' => sub {
|
|||
my $patron_mock = Test::MockModule->new('Koha::Patron');
|
||||
$patron_mock->mock( 'article_request_fee', sub { return $amount; } );
|
||||
|
||||
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
|
||||
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { lastseen => undef } } );
|
||||
my $item = $builder->build_sample_item;
|
||||
|
||||
my $ar_mock = Test::MockModule->new('Koha::ArticleRequest');
|
||||
|
|
@ -52,6 +52,7 @@ subtest 'request() tests' => sub {
|
|||
}
|
||||
);
|
||||
|
||||
t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', '' );
|
||||
$ar->request()->discard_changes;
|
||||
|
||||
is( $ar->status, Koha::ArticleRequest::Status::Requested );
|
||||
|
|
@ -59,6 +60,8 @@ subtest 'request() tests' => sub {
|
|||
|
||||
is( $ar->debit_id, undef, 'No fee linked' );
|
||||
is( $patron->account->balance, 0, 'No outstanding fees' );
|
||||
$patron->discard_changes;
|
||||
is( $patron->lastseen, undef, 'Patron activity not tracked when article is not a valid trigger' );
|
||||
|
||||
# set a fee amount
|
||||
$amount = 10;
|
||||
|
|
@ -71,6 +74,7 @@ subtest 'request() tests' => sub {
|
|||
}
|
||||
);
|
||||
|
||||
t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', 'article' );
|
||||
$ar->request()->discard_changes;
|
||||
|
||||
is( $ar->status, Koha::ArticleRequest::Status::Requested );
|
||||
|
|
@ -79,6 +83,8 @@ subtest 'request() tests' => sub {
|
|||
|
||||
ok( defined $ar->debit_id, 'Fee linked' );
|
||||
is( $patron->account->balance, $amount, 'Outstanding fees with the right value' );
|
||||
$patron->discard_changes;
|
||||
isnt( $patron->lastseen, undef, 'Patron activity tracked when article is a valid trigger' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1954,7 +1954,7 @@ subtest 'alert_subscriptions tests' => sub {
|
|||
|
||||
subtest 'update_lastseen tests' => sub {
|
||||
|
||||
plan tests => 21;
|
||||
plan tests => 24;
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
|
||||
|
|
@ -1969,7 +1969,7 @@ subtest 'update_lastseen tests' => sub {
|
|||
|
||||
t::lib::Mocks::mock_preference(
|
||||
'TrackLastPatronActivityTriggers',
|
||||
'login,connection,check_in,check_out,renewal,hold'
|
||||
'login,connection,check_in,check_out,renewal,hold,article'
|
||||
);
|
||||
|
||||
is( $patron->lastseen, undef, 'Patron should have not last seen when newly created' );
|
||||
|
|
@ -2003,6 +2003,9 @@ subtest 'update_lastseen tests' => sub {
|
|||
$patron->update_lastseen('hold');
|
||||
$patron->_result()->discard_changes();
|
||||
is( $patron->lastseen, $last_seen, 'Patron last seen should still be unchanged after a hold' );
|
||||
$patron->update_lastseen('article');
|
||||
$patron->_result()->discard_changes();
|
||||
is( $patron->lastseen, $last_seen, 'Patron last seen should still be unchanged after a article' );
|
||||
|
||||
# Check that tracking is disabled when the activity isn't listed
|
||||
t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', '' );
|
||||
|
|
@ -2048,11 +2051,17 @@ subtest 'update_lastseen tests' => sub {
|
|||
$patron->lastseen, $last_seen,
|
||||
'Patron last seen should be unchanged after a hold if hold is not selected as an option and the cache has been cleared'
|
||||
);
|
||||
$patron->update_lastseen('article');
|
||||
$patron->_result()->discard_changes();
|
||||
is(
|
||||
$patron->lastseen, $last_seen,
|
||||
'Patron last seen should be unchanged after an article request if article is not selected as an option and the cache has been cleared'
|
||||
);
|
||||
|
||||
# Check tracking for each activity
|
||||
t::lib::Mocks::mock_preference(
|
||||
'TrackLastPatronActivityTriggers',
|
||||
'login,connection,check_in,check_out,renewal,hold'
|
||||
'login,connection,check_in,check_out,renewal,hold,article'
|
||||
);
|
||||
|
||||
$cache->clear_from_cache($cache_key);
|
||||
|
|
@ -2091,6 +2100,12 @@ subtest 'update_lastseen tests' => sub {
|
|||
$patron->lastseen, $last_seen,
|
||||
'Patron last seen should be changed after a hold if we cleared the cache'
|
||||
);
|
||||
$patron->update_lastseen('article');
|
||||
$patron->_result()->discard_changes();
|
||||
isnt(
|
||||
$patron->lastseen, $last_seen,
|
||||
'Patron last seen should be changed after a article if we cleared the cache'
|
||||
);
|
||||
|
||||
$cache->clear_from_cache($cache_key);
|
||||
$patron->update_lastseen('renewal');
|
||||
|
|
|
|||
Loading…
Reference in New Issue