Skip to content

Commit

Permalink
Merge pull request #11691 from nextcloud/refactor/fix-usage-deprecate…
Browse files Browse the repository at this point in the history
…d-oc-webroot

Fix usage of deprecated OC.webroot
  • Loading branch information
MorrisJobke authored Oct 9, 2018
2 parents 7e7a14c + 9af69ca commit dcf5a57
Show file tree
Hide file tree
Showing 22 changed files with 102 additions and 102 deletions.
6 changes: 3 additions & 3 deletions apps/federatedfilesharing/tests/js/externalSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('OCA.Sharing external tests', function() {

var req = fakeServer.requests[0];
expect(req.method).toEqual('GET');
expect(req.url).toEqual(OC.webroot + '/index.php/apps/files_sharing/api/externalShares');
expect(req.url).toEqual(OC.getRootPath() + '/index.php/apps/files_sharing/api/externalShares');

req.respond(
200,
Expand Down Expand Up @@ -178,7 +178,7 @@ describe('OCA.Sharing external tests', function() {
expect(request.method).toEqual('POST');
expect(query).toEqual({id: '123'});
expect(request.url).toEqual(
OC.webroot + '/index.php/apps/files_sharing/api/externalShares'
OC.getRootPath() + '/index.php/apps/files_sharing/api/externalShares'
);

expect(plugin.filesApp.fileList.reload.notCalled).toEqual(true);
Expand All @@ -202,7 +202,7 @@ describe('OCA.Sharing external tests', function() {
var request = fakeServer.requests[1];
expect(request.method).toEqual('DELETE');
expect(request.url).toEqual(
OC.webroot + '/index.php/apps/files_sharing/api/externalShares/123'
OC.getRootPath() + '/index.php/apps/files_sharing/api/externalShares/123'
);

expect(plugin.filesApp.fileList.reload.notCalled).toEqual(true);
Expand Down
2 changes: 1 addition & 1 deletion apps/files/tests/js/favoritesfilelistspec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('OCA.Files.FavoritesFileList tests', function() {
expect($tr.attr('data-mime')).toEqual('text/plain');
expect($tr.attr('data-mtime')).toEqual('11111000');
expect($tr.find('a.name').attr('href')).toEqual(
OC.webroot +
OC.getRootPath() +
'/remote.php/webdav/somedir/test.txt'
);
expect($tr.find('.nametext').text().trim()).toEqual('test.txt');
Expand Down
2 changes: 1 addition & 1 deletion apps/files/tests/js/fileactionsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ describe('OCA.Files.FileActions tests', function() {
expect(busyStub.calledWith('testName.txt', true)).toEqual(true);
expect(handleDownloadStub.calledOnce).toEqual(true);
expect(handleDownloadStub.getCall(0).args[0]).toEqual(
OC.webroot + '/remote.php/webdav/subdir/testName.txt'
OC.getRootPath() + '/remote.php/webdav/subdir/testName.txt'
);
busyStub.reset();
handleDownloadStub.yield();
Expand Down
4 changes: 2 additions & 2 deletions apps/files/tests/js/fileactionsmenuSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ describe('OCA.Files.FileActionsMenu tests', function() {

expect(redirectStub.calledOnce).toEqual(true);
expect(redirectStub.getCall(0).args[0]).toContain(
OC.webroot +
OC.getRootPath() +
'/remote.php/webdav/subdir/testName.txt'
);
redirectStub.restore();
Expand Down Expand Up @@ -315,7 +315,7 @@ describe('OCA.Files.FileActionsMenu tests', function() {

expect(redirectStub.calledOnce).toEqual(true);
expect(redirectStub.getCall(0).args[0]).toContain(
OC.webroot + '/remote.php/webdav/anotherpath/there/testName.txt'
OC.getRootPath() + '/remote.php/webdav/anotherpath/there/testName.txt'
);
redirectStub.restore();
});
Expand Down
60 changes: 30 additions & 30 deletions apps/files/tests/js/filelistSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ describe('OCA.Files.FileList tests', function() {
filesClient = new OC.Files.Client({
host: 'localhost',
port: 80,
// FIXME: uncomment after fixing the test OC.webroot
//root: OC.webroot + '/remote.php/webdav',
// FIXME: uncomment after fixing the test OC.getRootPath()
//root: OC.getRootPath() + '/remote.php/webdav',
root: '/remote.php/webdav',
useHTTPS: false
});
Expand Down Expand Up @@ -232,7 +232,7 @@ describe('OCA.Files.FileList tests', function() {
expect($tr.attr('data-mtime')).toEqual('123456');
expect($tr.attr('data-e2eencrypted')).toEqual('false');
expect($tr.find('a.name').attr('href'))
.toEqual(OC.webroot + '/remote.php/webdav/subdir/testName.txt');
.toEqual(OC.getRootPath() + '/remote.php/webdav/subdir/testName.txt');
expect($tr.find('.nametext').text().trim()).toEqual('testName.txt');

expect($tr.find('.filesize').text()).toEqual('1 KB');
Expand Down Expand Up @@ -725,7 +725,7 @@ describe('OCA.Files.FileList tests', function() {

$tr = fileList.findFileEl('Tu_after_three.txt');
expect($tr.find('a.name').attr('href'))
.toEqual(OC.webroot + '/remote.php/webdav/some/subdir/Tu_after_three.txt');
.toEqual(OC.getRootPath() + '/remote.php/webdav/some/subdir/Tu_after_three.txt');
});
it('Triggers "fileActionsReady" event after rename', function() {
var handler = sinon.stub();
Expand Down Expand Up @@ -1412,7 +1412,7 @@ describe('OCA.Files.FileList tests', function() {
};
var $tr = fileList.add(fileData);
var $imgDiv = $tr.find('td.filename .thumbnail');
expect(OC.TestUtil.getImageUrl($imgDiv)).toEqual(OC.webroot + '/core/img/filetypes/file.svg');
expect(OC.TestUtil.getImageUrl($imgDiv)).toEqual(OC.getRootPath() + '/core/img/filetypes/file.svg');
// tries to load preview
expect(previewLoadStub.calledOnce).toEqual(true);
});
Expand All @@ -1424,45 +1424,45 @@ describe('OCA.Files.FileList tests', function() {

var $tr = fileList.add(fileData);
var $imgDiv = $tr.find('td.filename .thumbnail');
expect(OC.TestUtil.getImageUrl($imgDiv)).toEqual(OC.webroot + '/core/img/filetypes/folder.svg');
expect(OC.TestUtil.getImageUrl($imgDiv)).toEqual(OC.getRootPath() + '/core/img/filetypes/folder.svg');
// no preview since it's a directory
expect(previewLoadStub.notCalled).toEqual(true);
});
it('renders provided icon for file when provided', function() {
var fileData = new FileInfo({
type: 'file',
name: 'test file',
icon: OC.webroot + '/core/img/filetypes/application-pdf.svg',
icon: OC.getRootPath() + '/core/img/filetypes/application-pdf.svg',
mimetype: 'application/pdf'
});
var $tr = fileList.add(fileData);
var $imgDiv = $tr.find('td.filename .thumbnail');
expect(OC.TestUtil.getImageUrl($imgDiv)).toEqual(OC.webroot + '/core/img/filetypes/application-pdf.svg');
expect(OC.TestUtil.getImageUrl($imgDiv)).toEqual(OC.getRootPath() + '/core/img/filetypes/application-pdf.svg');
// try loading preview
expect(previewLoadStub.calledOnce).toEqual(true);
});
it('renders provided icon for file when provided', function() {
var fileData = new FileInfo({
name: 'somefile.pdf',
icon: OC.webroot + '/core/img/filetypes/application-pdf.svg'
icon: OC.getRootPath() + '/core/img/filetypes/application-pdf.svg'
});

var $tr = fileList.add(fileData);
var $imgDiv = $tr.find('td.filename .thumbnail');
expect(OC.TestUtil.getImageUrl($imgDiv)).toEqual(OC.webroot + '/core/img/filetypes/application-pdf.svg');
expect(OC.TestUtil.getImageUrl($imgDiv)).toEqual(OC.getRootPath() + '/core/img/filetypes/application-pdf.svg');
// try loading preview
expect(previewLoadStub.calledOnce).toEqual(true);
});
it('renders provided icon for folder when provided', function() {
var fileData = new FileInfo({
name: 'some folder',
mimetype: 'httpd/unix-directory',
icon: OC.webroot + '/core/img/filetypes/folder-alt.svg'
icon: OC.getRootPath() + '/core/img/filetypes/folder-alt.svg'
});

var $tr = fileList.add(fileData);
var $imgDiv = $tr.find('td.filename .thumbnail');
expect(OC.TestUtil.getImageUrl($imgDiv)).toEqual(OC.webroot + '/core/img/filetypes/folder-alt.svg');
expect(OC.TestUtil.getImageUrl($imgDiv)).toEqual(OC.getRootPath() + '/core/img/filetypes/folder-alt.svg');
// do not load preview for folders
expect(previewLoadStub.notCalled).toEqual(true);
});
Expand All @@ -1474,11 +1474,11 @@ describe('OCA.Files.FileList tests', function() {
var $tr = fileList.add(fileData);
var $td = $tr.find('td.filename');
expect(OC.TestUtil.getImageUrl($td.find('.thumbnail')))
.toEqual(OC.webroot + '/core/img/filetypes/file.svg');
.toEqual(OC.getRootPath() + '/core/img/filetypes/file.svg');
expect(previewLoadStub.calledOnce).toEqual(true);
// third argument is callback
previewLoadStub.getCall(0).args[0].callback(OC.webroot + '/somepath.png');
expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.webroot + '/somepath.png');
previewLoadStub.getCall(0).args[0].callback(OC.getRootPath() + '/somepath.png');
expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.getRootPath() + '/somepath.png');
});
it('does not render preview for directories', function() {
var fileData = {
Expand All @@ -1488,7 +1488,7 @@ describe('OCA.Files.FileList tests', function() {
};
var $tr = fileList.add(fileData);
var $td = $tr.find('td.filename');
expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.webroot + '/core/img/filetypes/folder.svg');
expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.getRootPath() + '/core/img/filetypes/folder.svg');
expect(previewLoadStub.notCalled).toEqual(true);
});
it('render encrypted folder icon for encrypted root', function() {
Expand All @@ -1500,7 +1500,7 @@ describe('OCA.Files.FileList tests', function() {
};
var $tr = fileList.add(fileData);
var $td = $tr.find('td.filename');
expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.webroot + '/core/img/filetypes/folder-encrypted.svg');
expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.getRootPath() + '/core/img/filetypes/folder-encrypted.svg');
expect(previewLoadStub.notCalled).toEqual(true);
});
it('render encrypted folder icon for encrypted subdir', function() {
Expand All @@ -1512,10 +1512,10 @@ describe('OCA.Files.FileList tests', function() {
};
var $tr = fileList.add(fileData);
var $td = $tr.find('td.filename');
expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.webroot + '/core/img/filetypes/folder-encrypted.svg');
expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.getRootPath() + '/core/img/filetypes/folder-encrypted.svg');
expect(previewLoadStub.notCalled).toEqual(true);
// default icon override
expect($tr.attr('data-icon')).toEqual(OC.webroot + '/core/img/filetypes/folder-encrypted.svg');
expect($tr.attr('data-icon')).toEqual(OC.getRootPath() + '/core/img/filetypes/folder-encrypted.svg');
});
it('render external storage icon for external storage root', function() {
var fileData = {
Expand All @@ -1526,7 +1526,7 @@ describe('OCA.Files.FileList tests', function() {
};
var $tr = fileList.add(fileData);
var $td = $tr.find('td.filename');
expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.webroot + '/core/img/filetypes/folder-external.svg');
expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.getRootPath() + '/core/img/filetypes/folder-external.svg');
expect(previewLoadStub.notCalled).toEqual(true);
});
it('render external storage icon for external storage subdir', function() {
Expand All @@ -1538,10 +1538,10 @@ describe('OCA.Files.FileList tests', function() {
};
var $tr = fileList.add(fileData);
var $td = $tr.find('td.filename');
expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.webroot + '/core/img/filetypes/folder-external.svg');
expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.getRootPath() + '/core/img/filetypes/folder-external.svg');
expect(previewLoadStub.notCalled).toEqual(true);
// default icon override
expect($tr.attr('data-icon')).toEqual(OC.webroot + '/core/img/filetypes/folder-external.svg');
expect($tr.attr('data-icon')).toEqual(OC.getRootPath() + '/core/img/filetypes/folder-external.svg');
});

});
Expand Down Expand Up @@ -1811,20 +1811,20 @@ describe('OCA.Files.FileList tests', function() {
describe('Download Url', function() {
it('returns correct download URL for single files', function() {
expect(fileList.getDownloadUrl('some file.txt'))
.toEqual(OC.webroot + '/remote.php/webdav/subdir/some%20file.txt');
.toEqual(OC.getRootPath() + '/remote.php/webdav/subdir/some%20file.txt');
expect(fileList.getDownloadUrl('some file.txt', '/anotherpath/abc'))
.toEqual(OC.webroot + '/remote.php/webdav/anotherpath/abc/some%20file.txt');
.toEqual(OC.getRootPath() + '/remote.php/webdav/anotherpath/abc/some%20file.txt');
$('#dir').val('/');
expect(fileList.getDownloadUrl('some file.txt'))
.toEqual(OC.webroot + '/remote.php/webdav/some%20file.txt');
.toEqual(OC.getRootPath() + '/remote.php/webdav/some%20file.txt');
});
it('returns correct download URL for multiple files', function() {
expect(fileList.getDownloadUrl(['a b c.txt', 'd e f.txt']))
.toEqual(OC.webroot + '/index.php/apps/files/ajax/download.php?dir=%2Fsubdir&files=%5B%22a%20b%20c.txt%22%2C%22d%20e%20f.txt%22%5D');
.toEqual(OC.getRootPath() + '/index.php/apps/files/ajax/download.php?dir=%2Fsubdir&files=%5B%22a%20b%20c.txt%22%2C%22d%20e%20f.txt%22%5D');
});
it('returns the correct ajax URL', function() {
expect(fileList.getAjaxUrl('test', {a:1, b:'x y'}))
.toEqual(OC.webroot + '/index.php/apps/files/ajax/test.php?a=1&b=x%20y');
.toEqual(OC.getRootPath() + '/index.php/apps/files/ajax/test.php?a=1&b=x%20y');
});
});
describe('File selection', function() {
Expand Down Expand Up @@ -2239,21 +2239,21 @@ describe('OCA.Files.FileList tests', function() {
it('Opens download URL when clicking "Download"', function() {
$('.selectedActions .filesSelectMenu .download').click();
expect(redirectStub.calledOnce).toEqual(true);
expect(redirectStub.getCall(0).args[0]).toContain(OC.webroot + '/index.php/apps/files/ajax/download.php?dir=%2Fsubdir&files=%5B%22One.txt%22%2C%22Three.pdf%22%2C%22somedir%22%5D');
expect(redirectStub.getCall(0).args[0]).toContain(OC.getRootPath() + '/index.php/apps/files/ajax/download.php?dir=%2Fsubdir&files=%5B%22One.txt%22%2C%22Three.pdf%22%2C%22somedir%22%5D');
redirectStub.restore();
});
it('Downloads root folder when all selected in root folder', function() {
$('#dir').val('/');
$('.select-all').click();
$('.selectedActions .filesSelectMenu .download').click();
expect(redirectStub.calledOnce).toEqual(true);
expect(redirectStub.getCall(0).args[0]).toContain(OC.webroot + '/index.php/apps/files/ajax/download.php?dir=%2F&files=');
expect(redirectStub.getCall(0).args[0]).toContain(OC.getRootPath() + '/index.php/apps/files/ajax/download.php?dir=%2F&files=');
});
it('Downloads parent folder when all selected in subfolder', function() {
$('.select-all').click();
$('.selectedActions .filesSelectMenu .download').click();
expect(redirectStub.calledOnce).toEqual(true);
expect(redirectStub.getCall(0).args[0]).toContain(OC.webroot + '/index.php/apps/files/ajax/download.php?dir=%2F&files=subdir');
expect(redirectStub.getCall(0).args[0]).toContain(OC.getRootPath() + '/index.php/apps/files/ajax/download.php?dir=%2F&files=subdir');
});

afterEach(function() {
Expand Down
6 changes: 3 additions & 3 deletions apps/files/tests/js/filesSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ describe('OCA.Files.Files tests', function() {
describe('getDownloadUrl', function() {
it('returns the ajax download URL when filename and dir specified', function() {
var url = Files.getDownloadUrl('test file.txt', '/subdir');
expect(url).toEqual(OC.webroot + '/remote.php/webdav/subdir/test%20file.txt');
expect(url).toEqual(OC.getRootPath() + '/remote.php/webdav/subdir/test%20file.txt');
});
it('returns the webdav download URL when filename and root dir specified', function() {
var url = Files.getDownloadUrl('test file.txt', '/');
expect(url).toEqual(OC.webroot + '/remote.php/webdav/test%20file.txt');
expect(url).toEqual(OC.getRootPath() + '/remote.php/webdav/test%20file.txt');
});
it('returns the ajax download URL when multiple files specified', function() {
var url = Files.getDownloadUrl(['test file.txt', 'abc.txt'], '/subdir');
expect(url).toEqual(OC.webroot + '/index.php/apps/files/ajax/download.php?dir=%2Fsubdir&files=%5B%22test%20file.txt%22%2C%22abc.txt%22%5D');
expect(url).toEqual(OC.getRootPath() + '/index.php/apps/files/ajax/download.php?dir=%2Fsubdir&files=%5B%22test%20file.txt%22%2C%22abc.txt%22%5D');
});
});
describe('handleDownload', function() {
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/js/statusmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ OCA.External.StatusManager = {
} else {
defObj = $.ajax({
type: 'GET',
url: OC.webroot + '/index.php/apps/files_external/' + ((mountData.type === 'personal') ? 'userstorages' : 'userglobalstorages') + '/' + mountData.id,
url: OC.getRootPath() + '/index.php/apps/files_external/' + ((mountData.type === 'personal') ? 'userstorages' : 'userglobalstorages') + '/' + mountData.id,
data: {'testOnly' : false},
success: function (response) {
if (response && response.status === 0) {
Expand Down
4 changes: 2 additions & 2 deletions apps/files_external/tests/js/mountsfilelistSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('OCA.External.FileList tests', function() {
expect($tr.attr('data-size')).not.toBeDefined();
expect($tr.attr('data-permissions')).toEqual('1'); // read only
expect($tr.find('a.name').attr('href')).toEqual(
OC.webroot +
OC.getRootPath() +
'/index.php/apps/files' +
'?dir=/another%20mount%20points/sftp%20mount'
);
Expand All @@ -139,7 +139,7 @@ describe('OCA.External.FileList tests', function() {
expect($tr.attr('data-size')).not.toBeDefined();
expect($tr.attr('data-permissions')).toEqual('9'); // read and delete
expect($tr.find('a.name').attr('href')).toEqual(
OC.webroot +
OC.getRootPath() +
'/index.php/apps/files' +
'?dir=/mount%20points/smb%20mount'
);
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/tests/js/settingsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ describe('OCA.External.Settings tests', function() {

expect(fakeServer.requests.length).toEqual(1);
var request = fakeServer.requests[0];
expect(request.url).toEqual(OC.webroot + '/index.php/apps/files_external/globalstorages');
expect(request.url).toEqual(OC.getRootPath() + '/index.php/apps/files_external/globalstorages');
expect(JSON.parse(request.requestBody)).toEqual({
backend: '\\OC\\TestBackend',
authMechanism: 'mechanism1',
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/js/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ OCA.Sharing.PublicApp = {
_legacyCreateFederatedShare: function (remote, token, owner, ownerDisplayName, name, isProtected) {

var self = this;
var location = window.location.protocol + '//' + window.location.host + OC.webroot;
var location = window.location.protocol + '//' + window.location.host + OC.getRootPath();

if(remote.substr(-1) !== '/') {
remote += '/'
Expand Down
12 changes: 6 additions & 6 deletions apps/files_sharing/tests/js/publicAppSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,24 @@ describe('OCA.Sharing.PublicApp tests', function() {

it('returns correct download URL for single files', function() {
expect(fileList.getDownloadUrl('some file.txt'))
.toEqual(OC.webroot + '/index.php/s/sh4tok/download?path=%2Fsubdir&files=some%20file.txt');
.toEqual(OC.getRootPath() + '/index.php/s/sh4tok/download?path=%2Fsubdir&files=some%20file.txt');
expect(fileList.getDownloadUrl('some file.txt', '/anotherpath/abc'))
.toEqual(OC.webroot + '/index.php/s/sh4tok/download?path=%2Fanotherpath%2Fabc&files=some%20file.txt');
.toEqual(OC.getRootPath() + '/index.php/s/sh4tok/download?path=%2Fanotherpath%2Fabc&files=some%20file.txt');
fileList.changeDirectory('/');
expect(fileList.getDownloadUrl('some file.txt'))
.toEqual(OC.webroot + '/index.php/s/sh4tok/download?path=%2F&files=some%20file.txt');
.toEqual(OC.getRootPath() + '/index.php/s/sh4tok/download?path=%2F&files=some%20file.txt');
});
it('returns correct download URL for multiple files', function() {
expect(fileList.getDownloadUrl(['a b c.txt', 'd e f.txt']))
.toEqual(OC.webroot + '/index.php/s/sh4tok/download?path=%2Fsubdir&files=%5B%22a%20b%20c.txt%22%2C%22d%20e%20f.txt%22%5D');
.toEqual(OC.getRootPath() + '/index.php/s/sh4tok/download?path=%2Fsubdir&files=%5B%22a%20b%20c.txt%22%2C%22d%20e%20f.txt%22%5D');
});
it('returns the correct ajax URL', function() {
expect(fileList.getAjaxUrl('test', {a:1, b:'x y'}))
.toEqual(OC.webroot + '/index.php/apps/files_sharing/ajax/test.php?a=1&b=x%20y&t=sh4tok');
.toEqual(OC.getRootPath() + '/index.php/apps/files_sharing/ajax/test.php?a=1&b=x%20y&t=sh4tok');
});
it('returns correct download URL for downloading everything', function() {
expect(fileList.getDownloadUrl())
.toEqual(OC.webroot + '/index.php/s/sh4tok/download?path=%2Fsubdir');
.toEqual(OC.getRootPath() + '/index.php/s/sh4tok/download?path=%2Fsubdir');
});
});
describe('Upload Url', function() {
Expand Down
Loading

0 comments on commit dcf5a57

Please sign in to comment.