From 81ec1c8a1ad208457eae772a20174abf4f6bafe7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 7 Apr 2015 11:11:31 +0200 Subject: [PATCH] Remove hardcoded link to performance docs --- core/js/setupchecks.js | 2 +- core/js/tests/specs/setupchecksSpec.js | 8 ++++---- settings/application.php | 1 + settings/controller/checksetupcontroller.php | 7 +++++++ .../controller/CheckSetupControllerTest.php | 17 ++++++++++++++--- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index 82c068cd68..9bb3face75 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -61,7 +61,7 @@ } if(!data.isMemcacheConfigured) { messages.push( - t('core', 'No memory cache has been configured. To enhance your performance please configure a memcache if available. Further information can be found in our documentation.') + t('core', 'No memory cache has been configured. To enhance your performance please configure a memcache if available. Further information can be found in our documentation.', {docLink: data.memcacheDocs}) ); } } else { diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index 779faa2544..3e6382603f 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -66,11 +66,11 @@ describe('OC.SetupChecks tests', function() { { 'Content-Type': 'application/json' }, - JSON.stringify({serverHasInternetConnection: false}) + JSON.stringify({serverHasInternetConnection: false, memcacheDocs: 'https://doc.owncloud.org/server/go.php?to=admin-performance'}) ); async.done(function( data, s, x ){ - expect(data).toEqual(['This server has no working Internet connection. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. We suggest to enable Internet connection for this server if you want to have all features.', 'Your data directory and your files are probably accessible from the Internet. The .htaccess file is not working. We strongly suggest that you configure your web server in a way that the data directory is no longer accessible or you move the data directory outside the web server document root.', 'No memory cache has been configured. To enhance your performance please configure a memcache if available. Further information can be found in our documentation.']); + expect(data).toEqual(['This server has no working Internet connection. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. We suggest to enable Internet connection for this server if you want to have all features.', 'Your data directory and your files are probably accessible from the Internet. The .htaccess file is not working. We strongly suggest that you configure your web server in a way that the data directory is no longer accessible or you move the data directory outside the web server document root.', 'No memory cache has been configured. To enhance your performance please configure a memcache if available. Further information can be found in our documentation.']); done(); }); }); @@ -83,11 +83,11 @@ describe('OC.SetupChecks tests', function() { { 'Content-Type': 'application/json' }, - JSON.stringify({serverHasInternetConnection: false, dataDirectoryProtected: false}) + JSON.stringify({serverHasInternetConnection: false, dataDirectoryProtected: false, memcacheDocs: 'https://doc.owncloud.org/server/go.php?to=admin-performance'}) ); async.done(function( data, s, x ){ - expect(data).toEqual(['This server has no working Internet connection. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. We suggest to enable Internet connection for this server if you want to have all features.', 'Your data directory and your files are probably accessible from the Internet. The .htaccess file is not working. We strongly suggest that you configure your web server in a way that the data directory is no longer accessible or you move the data directory outside the web server document root.', 'No memory cache has been configured. To enhance your performance please configure a memcache if available. Further information can be found in our documentation.']); + expect(data).toEqual(['This server has no working Internet connection. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. We suggest to enable Internet connection for this server if you want to have all features.', 'Your data directory and your files are probably accessible from the Internet. The .htaccess file is not working. We strongly suggest that you configure your web server in a way that the data directory is no longer accessible or you move the data directory outside the web server document root.', 'No memory cache has been configured. To enhance your performance please configure a memcache if available. Further information can be found in our documentation.']); done(); }); }); diff --git a/settings/application.php b/settings/application.php index b459603796..eb8f0f7a99 100644 --- a/settings/application.php +++ b/settings/application.php @@ -124,6 +124,7 @@ class Application extends App { $c->query('Request'), $c->query('Config'), $c->query('ClientService'), + $c->query('URLGenerator'), $c->query('Util') ); }); diff --git a/settings/controller/checksetupcontroller.php b/settings/controller/checksetupcontroller.php index ae3f1b99c5..15719ce215 100644 --- a/settings/controller/checksetupcontroller.php +++ b/settings/controller/checksetupcontroller.php @@ -27,6 +27,7 @@ use OCP\Http\Client\IClientService; use OCP\IConfig; use OCP\IRequest; use OC_Util; +use OCP\IURLGenerator; /** * @package OC\Settings\Controller @@ -38,23 +39,28 @@ class CheckSetupController extends Controller { private $clientService; /** @var \OC_Util */ private $util; + /** @var IURLGenerator */ + private $urlGenerator; /** * @param string $AppName * @param IRequest $request * @param IConfig $config * @param IClientService $clientService + * @param IURLGenerator $urlGenerator * @param \OC_Util $util */ public function __construct($AppName, IRequest $request, IConfig $config, IClientService $clientService, + IURLGenerator $urlGenerator, \OC_Util $util) { parent::__construct($AppName, $request); $this->config = $config; $this->clientService = $clientService; $this->util = $util; + $this->urlGenerator = $urlGenerator; } /** @@ -93,6 +99,7 @@ class CheckSetupController extends Controller { 'serverHasInternetConnection' => $this->isInternetConnectionWorking(), 'dataDirectoryProtected' => $this->util->isHtaccessWorking($this->config), 'isMemcacheConfigured' => $this->isMemcacheConfigured(), + 'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'), ] ); } diff --git a/tests/settings/controller/CheckSetupControllerTest.php b/tests/settings/controller/CheckSetupControllerTest.php index fc17d2adc4..26f9f4e945 100644 --- a/tests/settings/controller/CheckSetupControllerTest.php +++ b/tests/settings/controller/CheckSetupControllerTest.php @@ -22,11 +22,12 @@ namespace OC\Settings\Controller; use OCP\AppFramework\Http\DataResponse; -use Test\TestCase; -use OCP\IRequest; -use OCP\IConfig; use OCP\Http\Client\IClientService; +use OCP\IConfig; +use OCP\IRequest; +use OCP\IURLGenerator; use OC_Util; +use Test\TestCase; /** * Class CheckSetupControllerTest @@ -42,6 +43,8 @@ class CheckSetupControllerTest extends TestCase { private $config; /** @var IClientService */ private $clientService; + /** @var IURLGenerator */ + private $urlGenerator; /** @var OC_Util */ private $util; @@ -58,12 +61,15 @@ class CheckSetupControllerTest extends TestCase { ->disableOriginalConstructor()->getMock(); $this->util = $this->getMockBuilder('\OC_Util') ->disableOriginalConstructor()->getMock(); + $this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator') + ->disableOriginalConstructor()->getMock(); $this->checkSetupController = new CheckSetupController( 'settings', $this->request, $this->config, $this->clientService, + $this->urlGenerator, $this->util ); } @@ -218,12 +224,17 @@ class CheckSetupControllerTest extends TestCase { $this->util->expects($this->once()) ->method('isHtaccessWorking') ->will($this->returnValue(true)); + $this->urlGenerator->expects($this->once()) + ->method('linkToDocs') + ->with('admin-performance') + ->willReturn('http://doc.owncloud.org/server/go.php?to=admin-performance'); $expected = new DataResponse( [ 'serverHasInternetConnection' => false, 'dataDirectoryProtected' => true, 'isMemcacheConfigured' => true, + 'memcacheDocs' => 'http://doc.owncloud.org/server/go.php?to=admin-performance', ] ); $this->assertEquals($expected, $this->checkSetupController->check());