aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2018-08-20 14:54:50 +0200
committerGitHub <noreply@github.com>2018-08-20 14:54:50 +0200
commit1b1c8b3e7612d617d8e1abb37e8543b9f7bdbc86 (patch)
treeb6f6efac0062027dae5a2c076cd910438534dc21
parent1c13e7863334784292cbff902d2a8f92f05693ed (diff)
parent2de34d77780a60de198ef82a3f17292db9f668a4 (diff)
downloadnextcloud-server-1b1c8b3e7612d617d8e1abb37e8543b9f7bdbc86.tar.gz
nextcloud-server-1b1c8b3e7612d617d8e1abb37e8543b9f7bdbc86.zip
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
-rw-r--r--apps/files/js/filelist.js2
-rw-r--r--apps/files/tests/js/filelistSpec.js31
2 files changed, 32 insertions, 1 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 8e7c60551a1..8fb8a021811 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -1738,7 +1738,7 @@
}
}
- if (persist) {
+ if (persist && OC.getCurrentUser().uid) {
$.post(OC.generateUrl('/apps/files/api/v1/sorting'), {
mode: sort,
direction: direction
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index 7947dd91f2d..50b336902b9 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -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({