Merge pull request #10738 from nextcloud/fix/10669/store-sorting-only-for-loggedin-users

Only send an update sort order request if there is an user
This commit is contained in:
blizzz 2018-08-20 14:54:50 +02:00 committed by GitHub
commit 1b1c8b3e76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions

View File

@ -1738,7 +1738,7 @@
}
}
if (persist) {
if (persist && OC.getCurrentUser().uid) {
$.post(OC.generateUrl('/apps/files/api/v1/sorting'), {
mode: sort,
direction: direction

View File

@ -2614,6 +2614,20 @@ describe('OCA.Files.FileList tests', function() {
});
});
describe('Sorting files', function() {
var getCurrentUserStub;
beforeEach(function() {
getCurrentUserStub = sinon.stub(OC, 'getCurrentUser').returns({
uid: 1,
displayName: 'user1'
});
});
afterEach(function() {
getCurrentUserStub.restore();
});
it('Toggles the sort indicator when clicking on a column header', function() {
var ASC_CLASS = fileList.SORT_INDICATOR_ASC_CLASS;
var DESC_CLASS = fileList.SORT_INDICATOR_DESC_CLASS;
@ -2739,6 +2753,23 @@ describe('OCA.Files.FileList tests', function() {
sortStub.restore();
});
describe('if no user logged in', function() {
beforeEach(function() {
getCurrentUserStub.returns({
uid: null,
displayName: 'Guest'
});
});
it('shouldn\'t send an update sort order request', function() {
OC.currentUser = false;
fileList.$el.find('.column-size .columntitle').click();
// check if there was no request
expect(fakeServer.requests.length).toEqual(0);
});
});
describe('with favorites', function() {
it('shows favorite files on top', function() {
testFiles.push(new FileInfo({