Bug 35508: Move logic to Koha::Patron::Attribute::store()
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 4624425bf8)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
ac1172bf6a
commit
2d340da8f8
|
|
@ -58,6 +58,10 @@ sub store {
|
|||
|
||||
Koha::Exceptions::Patron::Attribute::InvalidAttributeValue->throw( attribute => $self )
|
||||
unless $self->value_ok();
|
||||
C4::Context->dbh->do(
|
||||
"UPDATE borrowers SET updated_on = NOW() WHERE borrowernumber = ?", undef,
|
||||
$self->borrowernumber
|
||||
);
|
||||
|
||||
return $self->SUPER::store();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -591,7 +591,6 @@ if ((!$nok) and $nodouble and ($op eq 'cud-insert' or $op eq 'cud-save')){
|
|||
if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) {
|
||||
$patron->extended_attributes->filter_by_branch_limitations->delete;
|
||||
$patron->extended_attributes($extended_patron_attributes);
|
||||
$patron->set( { updated_on => "" } )->store;
|
||||
}
|
||||
|
||||
if ( $destination eq 'circ' and not C4::Auth::haspermission( C4::Context->userenv->{id}, { circulate => 'circulate_remaining_permissions' } ) ) {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,46 @@ my $builder = t::lib::TestBuilder->new;
|
|||
|
||||
subtest 'store() tests' => sub {
|
||||
|
||||
plan tests => 5;
|
||||
plan tests => 6;
|
||||
|
||||
subtest 'Update an attribute should update the patron "updated_on" field' => sub {
|
||||
|
||||
plan tests => 1;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
|
||||
my $updated_on = $patron->updated_on;
|
||||
|
||||
sleep 1; # Timestamps are in one second increments, so we need to wait one second
|
||||
|
||||
my $type = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Patron::Attribute::Types',
|
||||
value => {
|
||||
mandatory => 0,
|
||||
repeatable => 0,
|
||||
unique_id => 0,
|
||||
category_code => undef
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
my $attr = $patron->add_extended_attribute(
|
||||
{
|
||||
code => $type->code,
|
||||
attribute => 'TEST'
|
||||
}
|
||||
);
|
||||
|
||||
$attr->set( { attribute => 'TEST' } )->store();
|
||||
|
||||
$patron->discard_changes;
|
||||
|
||||
isnt( $updated_on, $patron->updated_on, "Updated on was updated by attribute storage" );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'repeatable attributes tests' => sub {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue