Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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