diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gallery/tests/Gallery_Rest_Helper_Test.php | 17 | ||||
-rw-r--r-- | modules/rest/controllers/rest.php | 13 | ||||
-rw-r--r-- | modules/rest/helpers/rest.php | 2 |
3 files changed, 18 insertions, 14 deletions
diff --git a/modules/gallery/tests/Gallery_Rest_Helper_Test.php b/modules/gallery/tests/Gallery_Rest_Helper_Test.php index ea1841d0..1bf0b1ca 100644 --- a/modules/gallery/tests/Gallery_Rest_Helper_Test.php +++ b/modules/gallery/tests/Gallery_Rest_Helper_Test.php @@ -55,7 +55,6 @@ class Gallery_Rest_Helper_Test extends Unit_Test_Case { public function gallery_rest_get_album_test() { $request = (object)array("path" => $this->_child->relative_path()); - print Kohana::debug($request) . "\n"; $this->assert_equal( json_encode(array("status" => "OK", @@ -70,6 +69,20 @@ class Gallery_Rest_Helper_Test extends Unit_Test_Case { "has_children" => false, "path" => $this->_photo->relative_path(), "title" => $this->_photo->title))))), - gallery_rest::get_album($request)); + gallery_rest::get($request)); + } + + public function gallery_rest_get_photo_test() { + $request = (object)array("path" => $this->_photo->relative_path()); + + $this->assert_equal( + json_encode(array("status" => "OK", + "photo" => array("path" => $this->_photo->relative_path(), + "title" => $this->_photo->title, + "thumb_url" => $this->_photo->thumb_url(), + "url" => $this->_photo->abs_url(), + "description" => $this->_photo->description, + "internet_address" => $this->_photo->slug))), + gallery_rest::get($request)); } } diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php index 0c88877a..1ec24493 100644 --- a/modules/rest/controllers/rest.php +++ b/modules/rest/controllers/rest.php @@ -48,16 +48,10 @@ class Rest_Controller extends Controller { public function __call($function, $args) { $request = $this->_normalize_request($args); - - if (empty($request->access_token)) { - print rest::forbidden("No access token supplied."); - return; - } - try { if ($this->_set_active_user($request->access_token)) { $handler_class = "{$function}_rest"; - $handler_method = "{$request->method}"; + $handler_method = $request->method; if (!method_exists($handler_class, $handler_method)) { print rest::not_implemented("$handler_class::$handler_method is not implemented"); @@ -67,7 +61,7 @@ class Rest_Controller extends Controller { print call_user_func(array($handler_class, $handler_method), $request); } } catch (Exception $e) { - print rest::internal_error($e); + print rest::internal_error($e->__toString()); } } @@ -83,9 +77,6 @@ class Rest_Controller extends Controller { } else { $request = new stdClass(); foreach (array_keys($_GET) as $key) { - if ($key == "request_key") { - continue; - } $request->$key = $this->input->get($key); } } diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php index 22c13be9..fbbd6733 100644 --- a/modules/rest/helpers/rest.php +++ b/modules/rest/helpers/rest.php @@ -49,7 +49,7 @@ class rest_Core { * Resource Not Found */ static function not_found($log_message=null) { - return self::_format_response(t("Internal error"), $log_message); + return self::_format_response(t("Resource not found"), $log_message); } /** |