summaryrefslogtreecommitdiff
path: root/modules/tag
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-12-30 17:08:01 -0800
committerTim Almdal <tnalmdal@shaw.ca>2009-12-30 17:08:01 -0800
commit11792a12bb2002a434217efabe232022dd253b67 (patch)
tree4df434a962072dd092a4a2dfa03175ec7e916f0d /modules/tag
parente6111e616b5d6282b8aeb1d1b09fc6d064caafe8 (diff)
1) Remove the rest::not_found method and replace it with "throw new Kohana_404_Exception
2) Don't use the input path to lookup the item via relative_path_cache. Instead use url::get_item_from_uri method.
Diffstat (limited to 'modules/tag')
-rw-r--r--modules/tag/helpers/tag_rest.php6
-rw-r--r--modules/tag/tests/Tag_Rest_Helper_Test.php27
2 files changed, 21 insertions, 12 deletions
diff --git a/modules/tag/helpers/tag_rest.php b/modules/tag/helpers/tag_rest.php
index ed6cfc1c..cfcf93b2 100644
--- a/modules/tag/helpers/tag_rest.php
+++ b/modules/tag/helpers/tag_rest.php
@@ -70,11 +70,11 @@ class tag_rest_Core {
->viewable()
->find();
if (!$item->loaded()) {
- return rest::not_found("Resource: {$path} missing.");
+ throw new Kohana_404_Exception();
}
if (!access::can("edit", $item)) {
- return rest::not_found("Resource: {$path} permission denied.");
+ throw new Kohana_404_Exception();
}
foreach ($tags as $tag) {
@@ -94,7 +94,7 @@ class tag_rest_Core {
->where("name", "=", $name)
->find();
if (!$tag->loaded()) {
- return rest::not_found("Tag: {$name} not found.");
+ throw new Kohana_404_Exception();
}
$tag->name = $request->new_name;
diff --git a/modules/tag/tests/Tag_Rest_Helper_Test.php b/modules/tag/tests/Tag_Rest_Helper_Test.php
index 6b1c9a33..4408bf4b 100644
--- a/modules/tag/tests/Tag_Rest_Helper_Test.php
+++ b/modules/tag/tests/Tag_Rest_Helper_Test.php
@@ -119,9 +119,12 @@ class Tag_Rest_Helper_Test extends Unit_Test_Case {
public function tag_rest_add_tags_for_item_not_found_test() {
$request = (object)array("path" => $this->_photo->relative_url() . "b",
"arguments" => array("new,one"));
- $this->assert_equal(
- json_encode(array("status" => "ERROR", "message" => "Resource not found")),
- tag_rest::post($request));
+ try {
+ tag_rest::post($request);
+ } catch (Kohana_404_Exception $k404) {
+ } catch (Exception $e) {
+ $this->assert_false(true, $e->__toString());
+ }
}
public function tag_rest_add_tags_for_item_no_access_test() {
@@ -129,9 +132,12 @@ class Tag_Rest_Helper_Test extends Unit_Test_Case {
$request = (object)array("path" => $this->_photo->relative_url(),
"arguments" => array("new,one"));
- $this->assert_equal(
- json_encode(array("status" => "ERROR", "message" => "Resource not found")),
- tag_rest::post($request));
+ try {
+ tag_rest::post($request);
+ } catch (Kohana_404_Exception $k404) {
+ } catch (Exception $e) {
+ $this->assert_false(true, $e->__toString());
+ }
}
public function tag_rest_add_tags_for_item_test() {
@@ -175,9 +181,12 @@ class Tag_Rest_Helper_Test extends Unit_Test_Case {
public function tag_rest_update_tags_not_found_test() {
$request = (object)array("arguments" => array("not"), "new_name" => "found");
- $this->assert_equal(
- json_encode(array("status" => "ERROR", "message" => "Resource not found")),
- tag_rest::put($request));
+ try {
+ tag_rest::put($request);
+ } catch (Kohana_404_Exception $k404) {
+ } catch (Exception $e) {
+ $this->assert_false(true, $e->__toString());
+ }
}
public function tag_rest_update_tags_test() {