diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-02-10 11:15:57 +0100 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-02-10 11:16:17 +0100 |
commit | 2d293fea4328123f9d20a73f8d1bac79e746c9bd (patch) | |
tree | ad39f8e42e0dbed63d5b532f527c2912ca3f3160 | |
parent | 285ec73695ad938272a7232b3648bae7a944d3d0 (diff) |
added another exception for collapsing folders
-rw-r--r-- | coffee/lib/owncloud.coffee | 10 | ||||
-rw-r--r-- | controller/foldercontroller.php | 3 | ||||
-rw-r--r-- | tests/controller/FolderControllerTest.php | 21 |
3 files changed, 29 insertions, 5 deletions
diff --git a/coffee/lib/owncloud.coffee b/coffee/lib/owncloud.coffee index 91618a3f4..537499135 100644 --- a/coffee/lib/owncloud.coffee +++ b/coffee/lib/owncloud.coffee @@ -26,9 +26,19 @@ angular.module('OC', []).config ['$httpProvider', ($httpProvider) -> $httpProvider.defaults.get['Content-Type'] = 'application/x-www-form-urlencoded' + $httpProvider.defaults.transformRequest = (data) -> if angular.isDefined(data) return data else return $.param(data) +] + +angular.module('OC').init ['$rootScope', 'Router', ($rootScope, Router) -> + init = -> + $rootScope.$broadcast('routesLoaded') + + # this registers a callback that is executed once the routes have + # finished loading. Before this you cant really do request + OC.Router.registerLoadedCallback(init) ]
\ No newline at end of file diff --git a/controller/foldercontroller.php b/controller/foldercontroller.php index 2e890cb5d..ba8ab4077 100644 --- a/controller/foldercontroller.php +++ b/controller/foldercontroller.php @@ -29,6 +29,7 @@ use \OCA\AppFramework\Controller\Controller; use \OCA\AppFramework\Core\API; use \OCA\AppFramework\Http\Request; use \OCA\AppFramework\Db\DoesNotExistException; +use \OCA\AppFramework\Db\MultipleObjectsReturnedException; class FolderController extends Controller { @@ -68,6 +69,8 @@ class FolderController extends Controller { return $this->renderJSON(array()); } catch (DoesNotExistException $e) { return $this->renderJSON(array(), $e->getMessage()); + } catch(MultipleObjectsReturnedException $e){ + return $this->renderJSON(array(), $e->getMessage()); } } diff --git a/tests/controller/FolderControllerTest.php b/tests/controller/FolderControllerTest.php index ac7ca30f0..1381f8916 100644 --- a/tests/controller/FolderControllerTest.php +++ b/tests/controller/FolderControllerTest.php @@ -27,8 +27,9 @@ namespace OCA\News\Controller; use \OCA\AppFramework\Http\Request; use \OCA\AppFramework\Http\JSONResponse; -use OCA\AppFramework\Utility\ControllerTestUtility; +use \OCA\AppFramework\Utility\ControllerTestUtility; use \OCA\AppFramework\Db\DoesNotExistException; +use \OCA\AppFramework\Db\MultipleObjectsReturnedException; require_once(__DIR__ . "/../classloader.php"); @@ -147,9 +148,7 @@ class FolderControllerTest extends ControllerTestUtility { } - public function testCollapseExceptionReturnsJSONError(){ - $errorMsg = 'exception'; - $ex = new DoesNotExistException($errorMsg); + private function collapseException($ex){ $urlParams = array('folderId' => 1); $this->folderMapper->expects($this->once()) ->method('setCollapsed') @@ -159,9 +158,21 @@ class FolderControllerTest extends ControllerTestUtility { $response = $this->controller->collapse(); - $expected = '{"status":"error","data":[],"msg":"' . $errorMsg . '"}'; + $expected = '{"status":"error","data":[],"msg":"' . $ex->getMessage() . '"}'; $this->assertEquals($expected, $response->render()); } + public function testCollapseDoesNotExistExceptionReturnsJSONError(){ + $ex = new DoesNotExistException('exception'); + $this->collapseException($ex); + } + + + public function testCollapseMultipleObjectsReturnedReturnsJSONError(){ + $ex = new MultipleObjectsReturnedException('exception'); + $this->collapseException($ex); + } + + }
\ No newline at end of file |