Bug 17992: REST api: Remove the use of ->unblessed from Cities controller
authorTomas Cohen Arazi <tomascohen@theke.io>
Wed, 25 Jan 2017 12:35:42 +0000 (09:35 -0300)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 3 Mar 2017 16:57:40 +0000 (16:57 +0000)
As bug 17932 adds TO_JSON to Koha::Object(s), there's no need for using
it. Also, as this is a reference implementation for developers to copy
and paste it is sensible to make this change even when this is not
causing any bug.

To test:
- Apply the patch
- Run:
  $ sudo koha-shell kohadev
 k$ cd kohaclone
 k$ prove t/db_dependent/api/v1/cities.t
=> SUCCESS: Tests still pass!
- Sign off :-D

Signed-off-by: Matthias Meusburger <matthias.meusburger@biblibre.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Koha/REST/V1/Cities.pm

index e8ababe..5d32ea9 100644 (file)
@@ -19,7 +19,6 @@ use Modern::Perl;
 
 use Mojo::Base 'Mojolicious::Controller';
 
-use C4::Auth qw( haspermission );
 use Koha::City;
 use Koha::Cities;
 
@@ -37,7 +36,7 @@ sub list {
     }
 
     return try {
-        $cities = Koha::Cities->search($filter)->unblessed;
+        $cities = Koha::Cities->search($filter);
         return $c->$cb( $cities, 200 );
     }
     catch {
@@ -59,7 +58,7 @@ sub get {
         return $c->$cb( { error => "City not found" }, 404 );
     }
 
-    return $c->$cb( $city->unblessed, 200 );
+    return $c->$cb( $city, 200 );
 }
 
 sub add {
@@ -69,7 +68,7 @@ sub add {
 
     return try {
         $city->store;
-        return $c->$cb( $city->unblessed, 200 );
+        return $c->$cb( $city, 200 );
     }
     catch {
         if ( $_->isa('DBIx::Class::Exception') ) {
@@ -91,7 +90,7 @@ sub update {
         $city = Koha::Cities->find( $args->{cityid} );
         $city->set( $args->{body} );
         $city->store();
-        return $c->$cb( $city->unblessed, 200 );
+        return $c->$cb( $city, 200 );
     }
     catch {
         if ( not defined $city ) {