Merge pull request #19558 from owncloud/sharing_sidebar_toggle_enforcedpass

Do not remove linkshare if there is none
This commit is contained in:
Roeland Douma 2015-10-05 21:40:37 +02:00
commit 97bade9108
2 changed files with 42 additions and 1 deletions

View File

@ -124,7 +124,11 @@
this.$el.find('#linkPassText').focus();
}
} else {
this.model.removeLinkShare();
if (this.model.get('linkShare').isLinkShare) {
this.model.removeLinkShare();
} else {
this.$el.find('#linkPass').slideToggle(OC.menuSpeed);
}
}
},

View File

@ -231,6 +231,43 @@ describe('OC.Share.ShareDialogView', function() {
expect(dialog.$el.find('#linkCheckbox').prop('checked')).toEqual(true);
expect(dialog.$el.find('#linkText').val()).toEqual(link);
});
describe('password', function() {
var slideToggleStub;
beforeEach(function() {
$('#allowShareWithLink').val('yes');
configModel.set({
enforcePasswordForPublicLink: false
});
slideToggleStub = sinon.stub($.fn, 'slideToggle');
});
afterEach(function() {
slideToggleStub.restore();
});
it('enforced but toggled does not fire request', function() {
configModel.set('enforcePasswordForPublicLink', true);
dialog.render();
dialog.$el.find('[name=linkCheckbox]').click();
// The password linkPass field is shown (slideToggle is called).
// No request is made yet
expect(slideToggleStub.callCount).toEqual(1);
expect(slideToggleStub.getCall(0).thisValue.eq(0).attr('id')).toEqual('linkPass');
expect(fakeServer.requests.length).toEqual(0);
// Now untoggle share by link
dialog.$el.find('[name=linkCheckbox]').click();
dialog.render();
// Password field disappears and no ajax requests have been made
expect(fakeServer.requests.length).toEqual(0);
expect(slideToggleStub.callCount).toEqual(2);
expect(slideToggleStub.getCall(1).thisValue.eq(0).attr('id')).toEqual('linkPass');
});
});
describe('expiration date', function() {
var shareData;
var shareItem;