Skip to content

Commit

Permalink
Merge pull request #10738 from nextcloud/fix/10669/store-sorting-only…
Browse files Browse the repository at this point in the history
…-for-loggedin-users

Only send an update sort order request if there is an user
  • Loading branch information
blizzz authored Aug 20, 2018
2 parents 1c13e78 + 2de34d7 commit 1b1c8b3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,7 @@
}
}

if (persist) {
if (persist && OC.getCurrentUser().uid) {
$.post(OC.generateUrl('/apps/files/api/v1/sorting'), {
mode: sort,
direction: direction
Expand Down
31 changes: 31 additions & 0 deletions apps/files/tests/js/filelistSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 1b1c8b3

Please sign in to comment.