From b4d56d3fd823974e39c064b4f59a17a85a0194bc Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 18 Dec 2019 13:49:59 +0000 Subject: [PATCH] Bug 22273: Modify Koha::ArticleRequest->store to fill created_on For a new record, store should fill created_on. The database will always update the timestamp updated_on. Since open also calls SUPER::store, we do not need to call it twice. Test plan: [1] Run t/db_dependent/ArticleRequests.t [2] In the interface, add two article requests. Change the status of one to PROCESSING. Check created_on and updated_on in the article_requests table. The changed request should have updated_on > created_on. Signed-off-by: Bernardo Gonzalez Kriegel [1] Tests pass ok 12 - New article request has created_on date set ok 13 - New article request has updated_on date set [2] Work as described. No errors Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize --- Koha/ArticleRequest.pm | 15 +++++---------- t/db_dependent/ArticleRequests.t | 5 +++-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Koha/ArticleRequest.pm b/Koha/ArticleRequest.pm index f2698e7f55..39f68b1711 100644 --- a/Koha/ArticleRequest.pm +++ b/Koha/ArticleRequest.pm @@ -196,16 +196,11 @@ will have notifications sent. sub store { my ($self) = @_; - - if ( $self->in_storage() ) { - my $now = dt_from_string(); - $self->updated_on($now); - - return $self->SUPER::store(); - } - else { - $self->open(); - return $self->SUPER::store(); + if ( $self->in_storage ) { + return $self->SUPER::store; + } else { + $self->created_on( dt_from_string() ); + return $self->open; } } diff --git a/t/db_dependent/ArticleRequests.t b/t/db_dependent/ArticleRequests.t index 44a99b7e62..9ede9eb53b 100755 --- a/t/db_dependent/ArticleRequests.t +++ b/t/db_dependent/ArticleRequests.t @@ -19,7 +19,7 @@ use Modern::Perl; use POSIX qw(strftime); -use Test::More tests => 56; +use Test::More tests => 57; use t::lib::TestBuilder; use t::lib::Mocks; @@ -101,7 +101,8 @@ like( $notify_message->content, qr{Title: $article_request_title}, 'Values from $article_request = Koha::ArticleRequests->find( $article_request->id ); ok( $article_request->id, 'Koha::ArticleRequest created' ); is( $article_request->status, Koha::ArticleRequest::Status::Pending, 'New article request has status of Open' ); -is( $article_request->updated_on, undef, 'New article request has not an updated_on date set yet' ); +isnt( $article_request->created_on, undef, 'New article request has created_on date set' ); +isnt( $article_request->updated_on, undef, 'New article request has updated_on date set' ); # process Koha::Notice::Messages->delete; -- 2.39.5