diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2013-12-19 14:09:59 +0100 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2013-12-19 14:09:59 +0100 |
commit | 28d28d8c9eb5ed9f184b572cfd16994c024e4227 (patch) | |
tree | 18899de14c93e01a64d28823577836d69038256a | |
parent | 11e170fc19b6dd64e77a7b7b2d53ab6d17018aed (diff) |
add serverside infrastructure for setting and remembering compact view
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | controller/usersettingscontroller.php | 26 | ||||
-rw-r--r-- | tests/unit/controller/UserSettingsControllerTest.php | 51 |
3 files changed, 78 insertions, 0 deletions
@@ -1,5 +1,6 @@ owncloud-news (1.801) * Add ability to rename feeds +* Compact view owncloud-news (1.605) * Adding feeds does not block the input box any more diff --git a/controller/usersettingscontroller.php b/controller/usersettingscontroller.php index fdbb69b88..9dd14fbf2 100644 --- a/controller/usersettingscontroller.php +++ b/controller/usersettingscontroller.php @@ -92,5 +92,31 @@ class UserSettingsController extends Controller { } + /** + * @IsAdminExemption + * @IsSubAdminExemption + * @Ajax + */ + public function isCompactView(){ + $compact = $this->api->getUserValue('compact'); + $params = array( + 'compact' => $compact === '1' + ); + return $this->renderJSON($params); + } + + + /** + * @IsAdminExemption + * @IsSubAdminExemption + * @Ajax + */ + public function setCompactView(){ + $isCompact = $this->params('compact'); + $this->api->setUserValue('compact', $isCompact); + + return $this->renderJSON(); + } + }
\ No newline at end of file diff --git a/tests/unit/controller/UserSettingsControllerTest.php b/tests/unit/controller/UserSettingsControllerTest.php index 421d45566..cdbebcf1f 100644 --- a/tests/unit/controller/UserSettingsControllerTest.php +++ b/tests/unit/controller/UserSettingsControllerTest.php @@ -63,6 +63,14 @@ class UserSettingsControllerTest extends ControllerTestUtility { $this->assertUserSettingsControllerAnnotations('getLanguage'); } + public function testIsCompactViewAnnotations(){ + $this->assertUserSettingsControllerAnnotations('isCompactView'); + } + + public function testSetCompactViewAnnotations(){ + $this->assertUserSettingsControllerAnnotations('setCompactView'); + } + public function testFoldersAnnotations(){ $this->assertUserSettingsControllerAnnotations('read'); @@ -132,4 +140,47 @@ class UserSettingsControllerTest extends ControllerTestUtility { } + public function testIsCompactView() { + $result = array( + 'compact' => true + ); + $this->api->expects($this->once()) + ->method('getUserValue') + ->with($this->equalTo('compact')) + ->will($this->returnValue('1')); + + $response = $this->controller->isCompactView(); + $this->assertEquals($result, $response->getParams()); + $this->assertTrue($response instanceof JSONResponse); + } + + + public function testUnsetCompactView(){ + $request = new Request(array('post' => array( + 'compact' => false + ))); + $this->controller = new UserSettingsController($this->api, $request); + + $this->api->expects($this->once()) + ->method('setUserValue') + ->with($this->equalTo('compact'), + $this->equalTo(false)); + $response = $this->controller->setCompactView(); + $this->assertTrue($response instanceof JSONResponse); + } + + public function testSetCompactView(){ + $request = new Request(array('post' => array( + 'compact' => true + ))); + $this->controller = new UserSettingsController($this->api, $request); + + $this->api->expects($this->once()) + ->method('setUserValue') + ->with($this->equalTo('compact'), + $this->equalTo(true)); + $response = $this->controller->setCompactView(); + $this->assertTrue($response instanceof JSONResponse); + } + }
\ No newline at end of file |