mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-13 23:42:12 +00:00
Add method to remove blank uuids
This commit is contained in:
parent
3153fbac3c
commit
59dc0cdb4f
2 changed files with 23 additions and 1 deletions
|
|
@ -109,6 +109,20 @@ describe('Invite to Group Controller', function() {
|
|||
|
||||
expect(scope.invitees).to.eql([{uuid: ''}]);
|
||||
});
|
||||
|
||||
it('removes blank fields from being sent', function() {
|
||||
groups.Group.invite.yields();
|
||||
scope.invitees = [{uuid: 'user1'}, {uuid: ''}, {uuid: 'user3'}];
|
||||
|
||||
scope.inviteNewUsers('uuid');
|
||||
|
||||
expect(groups.Group.invite).to.be.calledOnce;
|
||||
expect(groups.Group.invite).to.be.calledWith({
|
||||
gid: scope.group._id,
|
||||
}, {
|
||||
uuids: ['user1', 'user3']
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context('invalid invite method', function() {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ habitrpg.controller('InviteToGroupCtrl', ['$scope', 'User', 'Groups', 'injectedG
|
|||
});
|
||||
}
|
||||
else if (inviteMethod === 'uuid') {
|
||||
var uuids = _.pluck($scope.invitees, 'uuid');
|
||||
var uuids = _getOnlyUuids();
|
||||
Groups.Group.invite({gid: $scope.group._id}, {uuids: uuids}, function(){
|
||||
Notification.text(window.env.t('invitationsSent'));
|
||||
_resetInvitees();
|
||||
|
|
@ -41,6 +41,14 @@ habitrpg.controller('InviteToGroupCtrl', ['$scope', 'User', 'Groups', 'injectedG
|
|||
}
|
||||
}
|
||||
|
||||
function _getOnlyUuids() {
|
||||
var uuids = _.pluck($scope.invitees, 'uuid');
|
||||
var filteredUuids = _.filter(uuids, function(id) {
|
||||
return id != '';
|
||||
});
|
||||
return filteredUuids;
|
||||
}
|
||||
|
||||
function _resetInvitees() {
|
||||
var emptyEmails = [{name:"",email:""},{name:"",email:""}];
|
||||
var emptyInvitees = [{uuid: ''}];
|
||||
|
|
|
|||
Loading…
Reference in a new issue