Bug 13012 - suggestion.suggesteddate should be set to NOW if not defined
Test Plan: 1) Apply this patch 2) prove t/db_dependent/Koha/Suggestions.t Signed-off-by: Marc Véron <veron@veron.ch> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
8651016ce8
commit
b2a8e726fe
|
|
@ -22,6 +22,7 @@ use Modern::Perl;
|
|||
use Carp;
|
||||
|
||||
use Koha::Database;
|
||||
use Koha::DateUtils qw(dt_from_string);
|
||||
|
||||
use base qw(Koha::Object);
|
||||
|
||||
|
|
@ -35,6 +36,23 @@ Koha::Suggestion - Koha Suggestion object class
|
|||
|
||||
=cut
|
||||
|
||||
=head3 store
|
||||
|
||||
Override the default store behavior so that new suggestions have
|
||||
a suggesteddate of today
|
||||
|
||||
=cut
|
||||
|
||||
sub store {
|
||||
my ($self) = @_;
|
||||
|
||||
unless ( $self->suggesteddate() ) {
|
||||
$self->suggesteddate( dt_from_string()->ymd );
|
||||
}
|
||||
|
||||
return $self->SUPER::store();
|
||||
}
|
||||
|
||||
=head3 type
|
||||
|
||||
=cut
|
||||
|
|
|
|||
|
|
@ -19,11 +19,12 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 4;
|
||||
use Test::More tests => 5;
|
||||
|
||||
use Koha::Suggestion;
|
||||
use Koha::Suggestions;
|
||||
use Koha::Database;
|
||||
use Koha::DateUtils;
|
||||
|
||||
use t::lib::TestBuilder;
|
||||
|
||||
|
|
@ -46,6 +47,8 @@ my $new_suggestion_2 = Koha::Suggestion->new(
|
|||
}
|
||||
)->store;
|
||||
|
||||
is( $new_suggestion_1->suggesteddate, dt_from_string()->ymd, "If suggesteddate not passed in, it will default to today" );
|
||||
|
||||
like( $new_suggestion_1->suggestionid, qr|^\d+$|, 'Adding a new suggestion should have set the suggestionid' );
|
||||
is( Koha::Suggestions->search->count, $nb_of_suggestions + 2, 'The 2 suggestions should have been added' );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue