diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-01-21 17:23:49 +0300 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-01-25 12:45:02 +0300 |
commit | 0a1350d5ac306b4e8c2183b17d562319d69c4ac3 (patch) | |
tree | de943b8959c7a0cd20216a5011c441e85cbcda53 /apps/systemtags/tests | |
parent | d4198607ec0b54be22781c2f48037cd449ee2fea (diff) |
System tags sidebar selector now respects permissions
For admins: display the namespace behind the tag name.
For users: no namespace, don't display non-assignable tags in the
dropdown, display already assigned non-assignable tags with a different
style
Diffstat (limited to 'apps/systemtags/tests')
-rw-r--r-- | apps/systemtags/tests/js/systemtagsinfoviewSpec.js | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/apps/systemtags/tests/js/systemtagsinfoviewSpec.js b/apps/systemtags/tests/js/systemtagsinfoviewSpec.js index 971ad8fc17e..0fb4e7b22c2 100644 --- a/apps/systemtags/tests/js/systemtagsinfoviewSpec.js +++ b/apps/systemtags/tests/js/systemtagsinfoviewSpec.js @@ -20,13 +20,16 @@ */ describe('OCA.SystemTags.SystemTagsInfoView tests', function() { + var isAdminStub; var view; beforeEach(function() { view = new OCA.SystemTags.SystemTagsInfoView(); $('#testArea').append(view.$el); + isAdminStub = sinon.stub(OC, 'isUserAdmin').returns(true); }); afterEach(function() { + isAdminStub.restore(); view.remove(); view = undefined; }); @@ -73,7 +76,7 @@ describe('OCA.SystemTags.SystemTagsInfoView tests', function() { view = new OCA.SystemTags.SystemTagsInfoView(); view.selectedTagsCollection.add([ {id: '1', name: 'test1'}, - {id: '3', name: 'test3'} + {id: '3', name: 'test3', userVisible: false, userAssignable: false} ]); var callback = sinon.stub(); @@ -83,7 +86,31 @@ describe('OCA.SystemTags.SystemTagsInfoView tests', function() { expect(callback.getCall(0).args[0]).toEqual([{ id: '1', name: 'test1', userVisible: true, userAssignable: true }, { - id: '3', name: 'test3', userVisible: true, userAssignable: true + id: '3', name: 'test3', userVisible: false, userAssignable: false + }]); + + inputViewSpy.restore(); + }); + it('sets locked flag on non-assignable tags when user is not an admin', function() { + isAdminStub.returns(false); + + var inputViewSpy = sinon.spy(OC.SystemTags, 'SystemTagsInputField'); + var element = $('<input type="hidden" val="1,3"/>'); + view.remove(); + view = new OCA.SystemTags.SystemTagsInfoView(); + view.selectedTagsCollection.add([ + {id: '1', name: 'test1'}, + {id: '3', name: 'test3', userAssignable: false} + ]); + + var callback = sinon.stub(); + inputViewSpy.getCall(0).args[0].initSelection(element, callback); + + expect(callback.calledOnce).toEqual(true); + expect(callback.getCall(0).args[0]).toEqual([{ + id: '1', name: 'test1', userVisible: true, userAssignable: true + }, { + id: '3', name: 'test3', userVisible: true, userAssignable: false, locked: true }]); inputViewSpy.restore(); |