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 <bgkriegel@gmail.com>
[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 <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Joy Nelson <joy@bywatersolutions.com>
This commit is contained in:
Marcel de Rooy 2019-12-18 13:49:59 +00:00 committed by Joy Nelson
parent 06235e20ee
commit 116abbc530
2 changed files with 8 additions and 12 deletions

View File

@ -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;
}
}

View File

@ -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;