Fix share capabilities JS tests

Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
This commit is contained in:
Vincent Petry 2017-09-01 12:51:49 +02:00 committed by Roeland Jago Douma
parent 3285becdc1
commit 7466468af1
No known key found for this signature in database
GPG Key ID: F941078878347C0C
1 changed files with 24 additions and 1 deletions

View File

@ -25,6 +25,7 @@ describe('OC.Share.ShareItemModel', function() {
var fetchSharesDeferred, fetchReshareDeferred;
var fileInfoModel, configModel, model;
var oldCurrentUser;
var capsSpec;
beforeEach(function() {
oldCurrentUser = OC.currentUser;
@ -56,8 +57,15 @@ describe('OC.Share.ShareItemModel', function() {
configModel: configModel,
fileInfoModel: fileInfoModel
});
capsSpec = sinon.stub(OC, 'getCapabilities');
capsSpec.returns({
'files_sharing': {
'default_permissions': OC.PERMISSION_ALL
}
});
});
afterEach(function() {
capsSpec.restore();
if (fetchSharesStub) {
fetchSharesStub.restore();
}
@ -527,7 +535,22 @@ describe('OC.Share.ShareItemModel', function() {
});
expect(
testWithPermissions(OC.PERMISSION_UPDATE | OC.PERMISSION_SHARE)
).toEqual(OC.PERMISSION_READ | OC.PERMISSION_UPDATE | OC.PERMISSION_UPDATE);
).toEqual(OC.PERMISSION_READ | OC.PERMISSION_UPDATE);
});
it('uses default permissions from capabilities', function() {
capsSpec.returns({
'files_sharing': {
'default_permissions': OC.PERMISSION_READ | OC.PERMISSION_CREATE | OC.PERMISSION_SHARE
}
});
configModel.set('isResharingAllowed', true);
model.set({
reshare: {},
shares: []
});
expect(
testWithPermissions(OC.PERMISSION_ALL)
).toEqual(OC.PERMISSION_READ | OC.PERMISSION_CREATE | OC.PERMISSION_SHARE);
});
});
});