View | Details | Raw Unified | Return to bug 35027
Collapse All | Expand All

(-)a/C4/Reserves.pm (-1 / +4 lines)
Lines 258-263 sub AddReserve { Link Here
258
    )->store();
258
    )->store();
259
    $hold->set_waiting() if $found && $found eq 'W';
259
    $hold->set_waiting() if $found && $found eq 'W';
260
260
261
    # record patron activity
262
    $hold->patron->update_lastseen('hold');
263
261
    logaction( 'HOLDS', 'CREATE', $hold->id, $hold )
264
    logaction( 'HOLDS', 'CREATE', $hold->id, $hold )
262
        if C4::Context->preference('HoldsLog');
265
        if C4::Context->preference('HoldsLog');
263
266
Lines 273-279 sub AddReserve { Link Here
273
276
274
    # Send e-mail to librarian if syspref is active
277
    # Send e-mail to librarian if syspref is active
275
    if(C4::Context->preference("emailLibrarianWhenHoldIsPlaced")){
278
    if(C4::Context->preference("emailLibrarianWhenHoldIsPlaced")){
276
        my $patron = Koha::Patrons->find( $borrowernumber );
279
        my $patron = $hold->patron;
277
        my $library = $patron->library;
280
        my $library = $patron->library;
278
        if ( my $letter =  C4::Letters::GetPreparedLetter (
281
        if ( my $letter =  C4::Letters::GetPreparedLetter (
279
            module => 'reserves',
282
            module => 'reserves',
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+1 lines)
Lines 101-106 Patrons: Link Here
101
               check_out: "Checking out an item"
101
               check_out: "Checking out an item"
102
               renewal: "Renewing an item"
102
               renewal: "Renewing an item"
103
               check_in: "Returning an item"
103
               check_in: "Returning an item"
104
               hold: "Placing a hold on an item"
104
     -
105
     -
105
         - pref: AutoApprovePatronProfileSettings
106
         - pref: AutoApprovePatronProfileSettings
106
           choices:
107
           choices:
(-)a/t/db_dependent/Koha/Patron.t (-3 / +26 lines)
Lines 1954-1960 subtest 'alert_subscriptions tests' => sub { Link Here
1954
1954
1955
subtest 'update_lastseen tests' => sub {
1955
subtest 'update_lastseen tests' => sub {
1956
1956
1957
    plan tests => 18;
1957
    plan tests => 21;
1958
    $schema->storage->txn_begin;
1958
    $schema->storage->txn_begin;
1959
1959
1960
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
1960
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
Lines 1967-1973 subtest 'update_lastseen tests' => sub { Link Here
1967
    my $cache_key = "track_activity_" . $patron->borrowernumber;
1967
    my $cache_key = "track_activity_" . $patron->borrowernumber;
1968
    $cache->clear_from_cache($cache_key);
1968
    $cache->clear_from_cache($cache_key);
1969
1969
1970
    t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', 'login,connection,check_in,check_out,renewal' );
1970
    t::lib::Mocks::mock_preference(
1971
        'TrackLastPatronActivityTriggers',
1972
        'login,connection,check_in,check_out,renewal,hold'
1973
    );
1971
1974
1972
    is( $patron->lastseen, undef, 'Patron should have not last seen when newly created' );
1975
    is( $patron->lastseen, undef, 'Patron should have not last seen when newly created' );
1973
1976
Lines 1997-2002 subtest 'update_lastseen tests' => sub { Link Here
1997
    $patron->update_lastseen('renewal');
2000
    $patron->update_lastseen('renewal');
1998
    $patron->_result()->discard_changes();
2001
    $patron->_result()->discard_changes();
1999
    is( $patron->lastseen, $last_seen, 'Patron last seen should still be unchanged after a renewal' );
2002
    is( $patron->lastseen, $last_seen, 'Patron last seen should still be unchanged after a renewal' );
2003
    $patron->update_lastseen('hold');
2004
    $patron->_result()->discard_changes();
2005
    is( $patron->lastseen, $last_seen, 'Patron last seen should still be unchanged after a hold' );
2000
2006
2001
    # Check that tracking is disabled when the activity isn't listed
2007
    # Check that tracking is disabled when the activity isn't listed
2002
    t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', '' );
2008
    t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', '' );
Lines 2036-2044 subtest 'update_lastseen tests' => sub { Link Here
2036
        $patron->lastseen, $last_seen,
2042
        $patron->lastseen, $last_seen,
2037
        'Patron last seen should be unchanged after a renewal if renewal is not selected as an option and the cache has been cleared'
2043
        'Patron last seen should be unchanged after a renewal if renewal is not selected as an option and the cache has been cleared'
2038
    );
2044
    );
2045
    $patron->update_lastseen('hold');
2046
    $patron->_result()->discard_changes();
2047
    is(
2048
        $patron->lastseen, $last_seen,
2049
        'Patron last seen should be unchanged after a hold if hold is not selected as an option and the cache has been cleared'
2050
    );
2039
2051
2040
    # Check tracking for each activity
2052
    # Check tracking for each activity
2041
    t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', 'login,connection,check_in,check_out,renewal' );
2053
    t::lib::Mocks::mock_preference(
2054
        'TrackLastPatronActivityTriggers',
2055
        'login,connection,check_in,check_out,renewal,hold'
2056
    );
2042
2057
2043
    $cache->clear_from_cache($cache_key);
2058
    $cache->clear_from_cache($cache_key);
2044
    $patron->update_lastseen('login');
2059
    $patron->update_lastseen('login');
Lines 2069-2074 subtest 'update_lastseen tests' => sub { Link Here
2069
        'Patron last seen should be changed after a check_in if we cleared the cache'
2084
        'Patron last seen should be changed after a check_in if we cleared the cache'
2070
    );
2085
    );
2071
2086
2087
    $cache->clear_from_cache($cache_key);
2088
    $patron->update_lastseen('hold');
2089
    $patron->_result()->discard_changes();
2090
    isnt(
2091
        $patron->lastseen, $last_seen,
2092
        'Patron last seen should be changed after a hold if we cleared the cache'
2093
    );
2094
2072
    $cache->clear_from_cache($cache_key);
2095
    $cache->clear_from_cache($cache_key);
2073
    $patron->update_lastseen('renewal');
2096
    $patron->update_lastseen('renewal');
2074
    $patron->_result()->discard_changes();
2097
    $patron->_result()->discard_changes();
(-)a/t/db_dependent/Reserves.t (-4 / +8 lines)
Lines 1488-1499 subtest 'IsAvailableForItemLevelRequest() tests' => sub { Link Here
1488
1488
1489
subtest 'AddReserve() tests' => sub {
1489
subtest 'AddReserve() tests' => sub {
1490
1490
1491
    plan tests => 1;
1491
    plan tests => 2;
1492
1492
1493
    $schema->storage->txn_begin;
1493
    $schema->storage->txn_begin;
1494
1494
1495
    my $library = $builder->build_object({ class => 'Koha::Libraries' });
1495
    t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', 'hold' );
1496
    my $patron  = $builder->build_object({ class => 'Koha::Patrons' });
1496
1497
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
1498
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { lastseen => undef } } );
1497
    my $biblio  = $builder->build_sample_biblio;
1499
    my $biblio  = $builder->build_sample_biblio;
1498
1500
1499
    my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
1501
    my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
Lines 1526-1531 subtest 'AddReserve() tests' => sub { Link Here
1526
        }
1528
        }
1527
    );
1529
    );
1528
1530
1531
    $patron->discard_changes;
1532
    isnt( $patron->lastseen, undef, "Patron activity tracked when hold is a valid trigger" );
1533
1529
    $schema->storage->txn_rollback;
1534
    $schema->storage->txn_rollback;
1530
};
1535
};
1531
1536
1532
- 

Return to bug 35027