From e7e5333b1239b84aa166d41231ae711a43eb72d9 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 21 Jul 2014 13:03:14 +0200 Subject: [PATCH 1/3] Remove special case for css in OC.filePath --- core/js/js.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/js/js.js b/core/js/js.js index 4a9a5ce82f..6b1c9b8863 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -258,7 +258,7 @@ var OC={ filePath:function(app,type,file){ var isCore=OC.coreApps.indexOf(app)!==-1, link=OC.webroot; - if((file.substring(file.length-3) === 'php' || file.substring(file.length-3) === 'css') && !isCore){ + if(file.substring(file.length-3) === 'php' && !isCore){ link+='/index.php/apps/' + app; if (file != 'index.php') { link+='/'; From cabd70148f4b78d580712364a3bee00c35e60bba Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 9 Sep 2014 12:05:19 +0200 Subject: [PATCH 2/3] Add unittest for filePath --- core/js/tests/specs/coreSpec.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js index dd9d4a7927..2ad1eb7623 100644 --- a/core/js/tests/specs/coreSpec.js +++ b/core/js/tests/specs/coreSpec.js @@ -134,6 +134,24 @@ describe('Core base tests', function() { expect(escapeHTML('This is a good string without HTML.')).toEqual('This is a good string without HTML.'); }); }); + describe('filePath', function() { + it('Uses a direct link for css and images,' , function() { + OC.webroot = 'http://localhost'; + OC.appswebroots['files'] = OC.webroot + '/apps3/files'; + + expect(OC.filePath('core', 'css', 'style.css')).toEqual('http://localhost/core/css/style.css'); + expect(OC.filePath('files', 'css', 'style.css')).toEqual('http://localhost/apps3/files/css/style.css'); + expect(OC.filePath('core', 'img', 'image.png')).toEqual('http://localhost/core/img/image.png'); + expect(OC.filePath('files', 'img', 'image.png')).toEqual('http://localhost/apps3/files/img/image.png'); + }); + it('Routes PHP files via index.php,' , function() { + OC.webroot = 'http://localhost'; + OC.appswebroots['files'] = OC.webroot + '/apps3/files'; + + expect(OC.filePath('core', 'ajax', 'test.php')).toEqual('http://localhost/index.php/core/ajax/test.php'); + expect(OC.filePath('files', 'ajax', 'test.php')).toEqual('http://localhost/index.php/apps/files/ajax/test.php'); + }); + }); describe('Link functions', function() { var TESTAPP = 'testapp'; var TESTAPP_ROOT = OC.webroot + '/appsx/testapp'; From e3c99a8505da671f7721d5058ecc6ca296e87003 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 9 Sep 2014 13:08:50 +0200 Subject: [PATCH 3/3] Add beforeeach and aftereach --- core/js/tests/specs/coreSpec.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js index 2ad1eb7623..5db79ef2c5 100644 --- a/core/js/tests/specs/coreSpec.js +++ b/core/js/tests/specs/coreSpec.js @@ -135,19 +135,21 @@ describe('Core base tests', function() { }); }); describe('filePath', function() { - it('Uses a direct link for css and images,' , function() { + beforeEach(function() { OC.webroot = 'http://localhost'; OC.appswebroots['files'] = OC.webroot + '/apps3/files'; + }); + afterEach(function() { + delete OC.appswebroots['files']; + }); + it('Uses a direct link for css and images,' , function() { expect(OC.filePath('core', 'css', 'style.css')).toEqual('http://localhost/core/css/style.css'); expect(OC.filePath('files', 'css', 'style.css')).toEqual('http://localhost/apps3/files/css/style.css'); expect(OC.filePath('core', 'img', 'image.png')).toEqual('http://localhost/core/img/image.png'); expect(OC.filePath('files', 'img', 'image.png')).toEqual('http://localhost/apps3/files/img/image.png'); }); it('Routes PHP files via index.php,' , function() { - OC.webroot = 'http://localhost'; - OC.appswebroots['files'] = OC.webroot + '/apps3/files'; - expect(OC.filePath('core', 'ajax', 'test.php')).toEqual('http://localhost/index.php/core/ajax/test.php'); expect(OC.filePath('files', 'ajax', 'test.php')).toEqual('http://localhost/index.php/apps/files/ajax/test.php'); });