summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--coffee/lib/owncloud.coffee10
-rw-r--r--controller/foldercontroller.php3
-rw-r--r--tests/controller/FolderControllerTest.php21
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