|
|
|
@ -83,16 +83,6 @@ describe('OC.Share tests', function() {
|
|
|
|
|
expect($el.attr('data-item-source')).toEqual('123');
|
|
|
|
|
// TODO: expect that other parts are rendered correctly
|
|
|
|
|
});
|
|
|
|
|
it('shows default expiration date when set', function() {
|
|
|
|
|
oc_appconfig.core.defaultExpireDateEnabled = "yes";
|
|
|
|
|
oc_appconfig.core.defaultExpireDate = '';
|
|
|
|
|
// TODO: expect that default date was set
|
|
|
|
|
});
|
|
|
|
|
it('shows default expiration date is set but disabled', function() {
|
|
|
|
|
oc_appconfig.core.defaultExpireDateEnabled = "no";
|
|
|
|
|
oc_appconfig.core.defaultExpireDate = '';
|
|
|
|
|
// TODO: expect that default date was NOT set
|
|
|
|
|
});
|
|
|
|
|
describe('Share with link', function() {
|
|
|
|
|
// TODO: test ajax calls
|
|
|
|
|
// TODO: test password field visibility (whenever enforced or not)
|
|
|
|
@ -265,6 +255,135 @@ describe('OC.Share tests', function() {
|
|
|
|
|
OC.linkTo('', 'public.php')+'?service=files&t=anothertoken';
|
|
|
|
|
expect($('#dropdown #linkText').val()).toEqual(link);
|
|
|
|
|
});
|
|
|
|
|
describe('expiration date', function() {
|
|
|
|
|
var shareData;
|
|
|
|
|
var shareItem;
|
|
|
|
|
var clock;
|
|
|
|
|
|
|
|
|
|
function showDropDown() {
|
|
|
|
|
OC.Share.showDropDown(
|
|
|
|
|
'file',
|
|
|
|
|
123,
|
|
|
|
|
$container,
|
|
|
|
|
'http://localhost/dummylink',
|
|
|
|
|
31,
|
|
|
|
|
'folder'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
|
// pick a fake date
|
|
|
|
|
clock = sinon.useFakeTimers(new Date(2014, 0, 20, 14, 0, 0).getTime());
|
|
|
|
|
shareItem = {
|
|
|
|
|
displayname_owner: 'root',
|
|
|
|
|
expiration: null,
|
|
|
|
|
file_source: 123,
|
|
|
|
|
file_target: '/folder',
|
|
|
|
|
id: 20,
|
|
|
|
|
item_source: '123',
|
|
|
|
|
item_type: 'folder',
|
|
|
|
|
mail_send: '0',
|
|
|
|
|
parent: null,
|
|
|
|
|
path: '/folder',
|
|
|
|
|
permissions: OC.PERMISSION_READ,
|
|
|
|
|
share_type: OC.Share.SHARE_TYPE_LINK,
|
|
|
|
|
share_with: null,
|
|
|
|
|
stime: 1403884258,
|
|
|
|
|
storage: 1,
|
|
|
|
|
token: 'tehtoken',
|
|
|
|
|
uid_owner: 'root'
|
|
|
|
|
};
|
|
|
|
|
shareData = {
|
|
|
|
|
reshare: [],
|
|
|
|
|
shares: []
|
|
|
|
|
};
|
|
|
|
|
loadItemStub.returns(shareData);
|
|
|
|
|
oc_appconfig.core.defaultExpireDate = 7;
|
|
|
|
|
oc_appconfig.core.defaultExpireDateEnabled = false;
|
|
|
|
|
oc_appconfig.core.defaultExpireDateEnforced = false;
|
|
|
|
|
});
|
|
|
|
|
afterEach(function() {
|
|
|
|
|
clock.restore();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('does not check expiration date checkbox when no date was set', function() {
|
|
|
|
|
shareItem.expiration = null;
|
|
|
|
|
shareData.shares.push(shareItem);
|
|
|
|
|
showDropDown();
|
|
|
|
|
expect($('#dropdown [name=expirationCheckbox]').prop('checked')).toEqual(false);
|
|
|
|
|
expect($('#dropdown #expirationDate').val()).toEqual('');
|
|
|
|
|
});
|
|
|
|
|
it('does not check expiration date checkbox for new share', function() {
|
|
|
|
|
showDropDown();
|
|
|
|
|
expect($('#dropdown [name=expirationCheckbox]').prop('checked')).toEqual(false);
|
|
|
|
|
expect($('#dropdown #expirationDate').val()).toEqual('');
|
|
|
|
|
});
|
|
|
|
|
it('checks expiration date checkbox and populates field when expiration date was set', function() {
|
|
|
|
|
shareItem.expiration = 1234;
|
|
|
|
|
shareData.shares.push(shareItem);
|
|
|
|
|
showDropDown();
|
|
|
|
|
expect($('#dropdown [name=expirationCheckbox]').prop('checked')).toEqual(true);
|
|
|
|
|
expect($('#dropdown #expirationDate').val()).toEqual('1234');
|
|
|
|
|
});
|
|
|
|
|
it('sets default date when default date setting is enabled', function() {
|
|
|
|
|
/* jshint camelcase:false */
|
|
|
|
|
oc_appconfig.core.defaultExpireDateEnabled = true;
|
|
|
|
|
showDropDown();
|
|
|
|
|
$('#dropdown [name=linkCheckbox]').click();
|
|
|
|
|
// enabled by default
|
|
|
|
|
expect($('#dropdown [name=expirationCheckbox]').prop('checked')).toEqual(true);
|
|
|
|
|
// TODO: those zeros must go...
|
|
|
|
|
expect($('#dropdown #expirationDate').val()).toEqual('2014-1-27 00:00:00');
|
|
|
|
|
|
|
|
|
|
// disabling is allowed
|
|
|
|
|
$('#dropdown [name=expirationCheckbox]').click();
|
|
|
|
|
expect($('#dropdown [name=expirationCheckbox]').prop('checked')).toEqual(false);
|
|
|
|
|
});
|
|
|
|
|
it('enforces default date when enforced date setting is enabled', function() {
|
|
|
|
|
/* jshint camelcase:false */
|
|
|
|
|
oc_appconfig.core.defaultExpireDateEnabled = true;
|
|
|
|
|
oc_appconfig.core.defaultExpireDateEnforced = true;
|
|
|
|
|
showDropDown();
|
|
|
|
|
$('#dropdown [name=linkCheckbox]').click();
|
|
|
|
|
expect($('#dropdown [name=expirationCheckbox]').prop('checked')).toEqual(true);
|
|
|
|
|
// TODO: those zeros must go...
|
|
|
|
|
expect($('#dropdown #expirationDate').val()).toEqual('2014-1-27 00:00:00');
|
|
|
|
|
|
|
|
|
|
// disabling is not allowed
|
|
|
|
|
expect($('#dropdown [name=expirationCheckbox]').prop('disabled')).toEqual(true);
|
|
|
|
|
$('#dropdown [name=expirationCheckbox]').click();
|
|
|
|
|
expect($('#dropdown [name=expirationCheckbox]').prop('checked')).toEqual(true);
|
|
|
|
|
});
|
|
|
|
|
it('sets picker minDate to today and no maxDate by default', function() {
|
|
|
|
|
showDropDown();
|
|
|
|
|
$('#dropdown [name=linkCheckbox]').click();
|
|
|
|
|
$('#dropdown [name=expirationCheckbox]').click();
|
|
|
|
|
expect($.datepicker._defaults.minDate).toEqual(new Date());
|
|
|
|
|
expect($.datepicker._defaults.maxDate).toEqual(null);
|
|
|
|
|
});
|
|
|
|
|
it('limits the date range to X days after share time when enforced', function() {
|
|
|
|
|
/* jshint camelcase:false */
|
|
|
|
|
oc_appconfig.core.defaultExpireDateEnabled = true;
|
|
|
|
|
oc_appconfig.core.defaultExpireDateEnforced = true;
|
|
|
|
|
showDropDown();
|
|
|
|
|
$('#dropdown [name=linkCheckbox]').click();
|
|
|
|
|
expect($.datepicker._defaults.minDate).toEqual(new Date());
|
|
|
|
|
expect($.datepicker._defaults.maxDate).toEqual(new Date(2014, 0, 27, 0, 0, 0, 0));
|
|
|
|
|
});
|
|
|
|
|
it('limits the date range to X days after share time when enforced, even when redisplayed the next days', function() {
|
|
|
|
|
// item exists, was created two days ago
|
|
|
|
|
shareItem.expiration = '2014-1-27';
|
|
|
|
|
// share time has time component but must be stripped later
|
|
|
|
|
shareItem.stime = new Date(2014, 0, 20, 11, 0, 25).getTime() / 1000;
|
|
|
|
|
shareData.shares.push(shareItem);
|
|
|
|
|
/* jshint camelcase:false */
|
|
|
|
|
oc_appconfig.core.defaultExpireDateEnabled = true;
|
|
|
|
|
oc_appconfig.core.defaultExpireDateEnforced = true;
|
|
|
|
|
showDropDown();
|
|
|
|
|
expect($.datepicker._defaults.minDate).toEqual(new Date());
|
|
|
|
|
expect($.datepicker._defaults.maxDate).toEqual(new Date(2014, 0, 27, 0, 0, 0, 0));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
describe('"sharesChanged" event', function() {
|
|
|
|
|
var autocompleteOptions;
|
|
|
|
|