Bug 30392: Set deleted_on when an item is (marked as) deleted
We could like to track down when an item has been moved to the deleteditems table. Test plan: Created a new item, delete it Not that the deleteditems.deleted_on value is set correctly Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
959fe662ed
commit
36d1f18bd5
|
|
@ -337,6 +337,7 @@ sub move_to_deleted {
|
|||
my ($self) = @_;
|
||||
my $item_infos = $self->unblessed;
|
||||
delete $item_infos->{timestamp}; #This ensures the timestamp date in deleteditems will be set to the current timestamp
|
||||
$item_infos->{deleted_on} = dt_from_string;
|
||||
return Koha::Database->new->schema->resultset('Deleteditem')->create($item_infos);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ use List::MoreUtils qw(all);
|
|||
|
||||
use t::lib::TestBuilder;
|
||||
use t::lib::Mocks;
|
||||
use t::lib::Dates;
|
||||
|
||||
my $schema = Koha::Database->new->schema;
|
||||
my $builder = t::lib::TestBuilder->new;
|
||||
|
|
@ -765,7 +766,7 @@ subtest 'request_transfer' => sub {
|
|||
};
|
||||
|
||||
subtest 'deletion' => sub {
|
||||
plan tests => 13;
|
||||
plan tests => 15;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
|
|
@ -776,9 +777,13 @@ subtest 'deletion' => sub {
|
|||
biblionumber => $biblio->biblionumber,
|
||||
}
|
||||
);
|
||||
is( $item->deleted_on, undef, 'deleted_on not set for new item' );
|
||||
|
||||
is( ref( $item->move_to_deleted ), 'Koha::Schema::Result::Deleteditem', 'Koha::Item->move_to_deleted should return the Deleted item' )
|
||||
my $deleted_item = $item->move_to_deleted;
|
||||
is( ref( $deleted_item ), 'Koha::Schema::Result::Deleteditem', 'Koha::Item->move_to_deleted should return the Deleted item' )
|
||||
; # FIXME This should be Koha::Deleted::Item
|
||||
is( t::lib::Dates::compare( $deleted_item->deleted_on, dt_from_string() ), 0 );
|
||||
|
||||
is( Koha::Old::Items->search({itemnumber => $item->itemnumber})->count, 1, '->move_to_deleted must have moved the item to deleteditem' );
|
||||
$item = $builder->build_sample_item(
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue