diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-09-23 12:44:25 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-09-23 14:41:13 +0200 |
commit | 0db9b28f3fa6bfdc236218c84a507da47cd29e43 (patch) | |
tree | 3ba9917f3ba7ffb617ec561ac346a48d918b3439 /core/js/tests/specs/shareitemmodelSpec.js | |
parent | d54d9a573fac498c4aaeea0df832a204cf525b58 (diff) | |
download | nextcloud-server-0db9b28f3fa6bfdc236218c84a507da47cd29e43.tar.gz nextcloud-server-0db9b28f3fa6bfdc236218c84a507da47cd29e43.zip |
Fix ShareItemModel.hasUserShares to only check shares of current item
The shares array is based on what the server returns and can contain
share info for parent folders.
hasUserShares is now fixed to ignore parent folders and only checks for
shares on the current item.
Diffstat (limited to 'core/js/tests/specs/shareitemmodelSpec.js')
-rw-r--r-- | core/js/tests/specs/shareitemmodelSpec.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/core/js/tests/specs/shareitemmodelSpec.js b/core/js/tests/specs/shareitemmodelSpec.js index 07a6fbdc23f..b169962f1d6 100644 --- a/core/js/tests/specs/shareitemmodelSpec.js +++ b/core/js/tests/specs/shareitemmodelSpec.js @@ -304,6 +304,63 @@ describe('OC.Share.ShareItemModel', function() { expect(share.expiration).toEqual(1403900000); }); }); + describe('hasUserShares', function() { + it('returns false when no user shares exist', function() { + loadItemStub.yields({ + reshare: {}, + shares: [] + }); + + model.fetch(); + + expect(model.hasUserShares()).toEqual(false); + }); + it('returns true when user shares exist on the current item', function() { + loadItemStub.yields({ + reshare: {}, + shares: [{ + id: 1, + share_type: OC.Share.SHARE_TYPE_USER, + share_with: 'user1', + item_source: '123' + }] + }); + + model.fetch(); + + expect(model.hasUserShares()).toEqual(true); + }); + it('returns true when group shares exist on the current item', function() { + loadItemStub.yields({ + reshare: {}, + shares: [{ + id: 1, + share_type: OC.Share.SHARE_TYPE_GROUP, + share_with: 'group1', + item_source: '123' + }] + }); + + model.fetch(); + + expect(model.hasUserShares()).toEqual(true); + }); + it('returns false when share exist on parent item', function() { + loadItemStub.yields({ + reshare: {}, + shares: [{ + id: 1, + share_type: OC.Share.SHARE_TYPE_GROUP, + share_with: 'group1', + item_source: '111' + }] + }); + + model.fetch(); + + expect(model.hasUserShares()).toEqual(false); + }); + }); describe('Util', function() { it('parseTime should properly parse strings', function() { |