Bugzilla – Attachment 65845 Details for
Bug 13012
suggestion.suggesteddate should be set to NOW if not defined
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13012 - suggestion.suggesteddate should be set to NOW if not defined
Bug-13012---suggestionsuggesteddate-should-be-set-.patch (text/plain), 2.18 KB, created by
Jonathan Druart
on 2017-08-10 18:55:41 UTC
(
hide
)
Description:
Bug 13012 - suggestion.suggesteddate should be set to NOW if not defined
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-08-10 18:55:41 UTC
Size:
2.18 KB
patch
obsolete
>From af65e02fd8c46fc87328492b48df5c35615a0361 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 19 Jul 2017 14:57:26 -0400 >Subject: [PATCH] Bug 13012 - suggestion.suggesteddate should be set to NOW if > not defined >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >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> >--- > Koha/Suggestion.pm | 18 ++++++++++++++++++ > t/db_dependent/Koha/Suggestions.t | 5 ++++- > 2 files changed, 22 insertions(+), 1 deletion(-) > >diff --git a/Koha/Suggestion.pm b/Koha/Suggestion.pm >index a091f43f2a..2fef425197 100644 >--- a/Koha/Suggestion.pm >+++ b/Koha/Suggestion.pm >@@ -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 >diff --git a/t/db_dependent/Koha/Suggestions.t b/t/db_dependent/Koha/Suggestions.t >index e29f2af558..0a2af42345 100644 >--- a/t/db_dependent/Koha/Suggestions.t >+++ b/t/db_dependent/Koha/Suggestions.t >@@ -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' ); > >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13012
:
65127
|
65139
| 65845 |
65846