Bugzilla – Attachment 54339 Details for
Bug 17089
Move the star ratings related code to Koha::Ratings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17089: Mark out the boundaries of ratings
Bug-17089-Mark-out-the-boundaries-of-ratings.patch (text/plain), 2.46 KB, created by
Marcel de Rooy
on 2016-08-12 08:19:07 UTC
(
hide
)
Description:
Bug 17089: Mark out the boundaries of ratings
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2016-08-12 08:19:07 UTC
Size:
2.46 KB
patch
obsolete
>From 96da1b3de3729d3ae188958bf87b9fdaaec43001 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 9 Aug 2016 15:08:55 +0100 >Subject: [PATCH] Bug 17089: Mark out the boundaries of ratings >Content-Type: text/plain; charset=utf-8 > >In the doc of C4::Ratings, it was written that the rate values should be >>=0 and <=5, but it was not taken into account. >This bug should be fixed on stable releases as well. > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Rating.pm | 15 +++++++++++++++ > t/db_dependent/Koha/Ratings.t | 10 +++++++++- > 2 files changed, 24 insertions(+), 1 deletion(-) > >diff --git a/Koha/Rating.pm b/Koha/Rating.pm >index 1bdeb69..94186d0 100644 >--- a/Koha/Rating.pm >+++ b/Koha/Rating.pm >@@ -33,6 +33,21 @@ Koha::Rating - Koha Rating Object class > > =cut > >+=head3 store >+ >+=cut >+ >+sub store { >+ my ($self) = @_; >+ if ( $self->rating_value > 5 ) { >+ $self->rating_value(5); >+ } >+ elsif ( $self->rating_value < 0 ) { >+ $self->rating_value(0); >+ } >+ return $self->SUPER::store; >+} >+ > =head3 type > > =cut >diff --git a/t/db_dependent/Koha/Ratings.t b/t/db_dependent/Koha/Ratings.t >index 2d99e94..2f8ead9 100755 >--- a/t/db_dependent/Koha/Ratings.t >+++ b/t/db_dependent/Koha/Ratings.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 4; >+use Test::More tests => 6; > > use Koha::Database; > use Koha::Rating; >@@ -43,6 +43,14 @@ $rating_1->rating_value(5)->store; > > is( Koha::Ratings->search( { biblionumber => $biblionumber } )->get_avg_rating, 4.5, ); > >+$rating_1->rating_value(42)->store; >+is( Koha::Ratings->find( { biblionumber => $biblionumber, borrowernumber => $patron_1->{borrowernumber} } )->rating_value, >+ 5, 'Koha::Ratings->store should mark out the boundaries of the rating values, 5 is max' ); >+ >+$rating_1->rating_value(-42)->store; >+is( Koha::Ratings->find( { biblionumber => $biblionumber, borrowernumber => $patron_1->{borrowernumber} } )->rating_value, >+ 0, 'Koha::Ratings->store should mark out the boundaries of the rating values, 0 is min' ); >+ > Koha::Ratings->find( { biblionumber => $biblionumber, borrowernumber => $patron_1->{borrowernumber} } )->delete; > Koha::Ratings->find( { biblionumber => $biblionumber, borrowernumber => $patron_2->{borrowernumber} } )->delete; > is( Koha::Ratings->search( { biblionumber => $biblionumber } )->count, 0, 'Delete should have deleted the ratings' ); >-- >1.7.10.4
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 17089
:
54207
|
54208
|
54209
|
54210
|
54211
|
54212
|
54213
|
54214
|
54225
|
54230
|
54231
|
54232
|
54233
|
54234
|
54235
|
54236
|
54237
|
54238
|
54332
|
54333
|
54334
|
54335
|
54336
|
54337
|
54338
| 54339 |
54340
|
54341