From 4f223581e0f512933fa98b45526bc5960eb0cba1 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 7 Aug 2019 21:13:18 -0500 Subject: [PATCH] Bug 23463: update permanent_location if location has been updated This change to Koha::Item->store seems correct here, but tests from /db_dependent/Items.t is failing now. Adjusting them to make them pass. --- Koha/Item.pm | 2 +- t/db_dependent/Items.t | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index c66b04fbf0..575bb0757b 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -137,7 +137,7 @@ sub store { my %updated_columns = $self->_result->get_dirty_columns; return $self->SUPER::store unless %updated_columns; - if ( defined $self->location + if ( exists $updated_columns{location} and $self->location ne 'CART' and $self->location ne 'PROC' and not exists $updated_columns{permanent_location} ) diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index cb59de5995..57aaa725fe 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -108,15 +108,16 @@ subtest 'General Add, Get and Del tests' => sub { is( $getitem->location, $location, "The location should not have been modified" ); is( $getitem->permanent_location, 'my permanent location', "The permanent_location should not have modified" ); - $getitem->location($location)->store; + my $new_location = "New location"; + $getitem->location($new_location)->store; $getitem = Koha::Items->find($itemnumber); - is( $getitem->location, $location, "The location should have been set to correct location" ); - is( $getitem->permanent_location, $location, "The permanent_location should have been set to location" ); + is( $getitem->location, $new_location, "The location should have been set to correct location" ); + is( $getitem->permanent_location, $new_location, "The permanent_location should have been set to location" ); $getitem->location('CART')->store; $getitem = Koha::Items->find($itemnumber); is( $getitem->location, 'CART', "The location should have been set to CART" ); - is( $getitem->permanent_location, $location, "The permanent_location should not have been set to CART" ); + is( $getitem->permanent_location, $new_location, "The permanent_location should not have been set to CART" ); t::lib::Mocks::mock_preference('item-level_itypes', '1'); $getitem = Koha::Items->find($itemnumber); @@ -840,7 +841,7 @@ subtest 'Test logging for ModItem' => sub { # True means logging $schema->resultset('ActionLog')->search()->delete(); - $item->location($location)->store({ log_action => 1 }); + $item->location('new location')->store({ log_action => 1 }); is( $schema->resultset('ActionLog')->count(), 1, 'True value does trigger logging' ); # Undefined defaults to true -- 2.25.0