mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Provide group name if not provided and save
This commit is contained in:
@@ -45,10 +45,33 @@ describe('Invite to Group Controller', function() {
|
|||||||
|
|
||||||
describe('inviteNewUsers', function() {
|
describe('inviteNewUsers', function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
scope.group = specHelper.newGroup();
|
scope.group = specHelper.newGroup({
|
||||||
|
$save: sinon.stub().returns({
|
||||||
|
then: function(cb) { cb(); }
|
||||||
|
})
|
||||||
|
});
|
||||||
sandbox.stub(groups.Group, 'invite');
|
sandbox.stub(groups.Group, 'invite');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
context('pre-invite', function() {
|
||||||
|
it('saves the group', function() {
|
||||||
|
scope.inviteNewUsers('uuid');
|
||||||
|
expect(scope.group.$save).to.be.calledOnce;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('uses provided name', function() {
|
||||||
|
scope.group.name = 'test party';
|
||||||
|
scope.inviteNewUsers('uuid');
|
||||||
|
expect(group.name).to.eql('test party');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('names the group if no name is provided', function() {
|
||||||
|
scope.group.name = '';
|
||||||
|
scope.inviteNewUsers('uuid');
|
||||||
|
expect(group.name).to.eql(env.t('possessiveParty', {name: user.profile.name}));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
context('email', function() {
|
context('email', function() {
|
||||||
it('invites user with emails', function() {
|
it('invites user with emails', function() {
|
||||||
scope.emails = [
|
scope.emails = [
|
||||||
|
|||||||
@@ -15,7 +15,14 @@ habitrpg.controller('InviteToGroupCtrl', ['$scope', 'User', 'Groups', 'injectedG
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.inviteNewUsers = function(inviteMethod) {
|
$scope.inviteNewUsers = function(inviteMethod) {
|
||||||
_inviteByMethod(inviteMethod);
|
if (!$scope.group.name) {
|
||||||
|
$scope.group.name = env.t('possessiveParty', {name: User.user.profile.name});
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.group.$save()
|
||||||
|
.then(function(res) {
|
||||||
|
_inviteByMethod(inviteMethod);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function _inviteByMethod(inviteMethod) {
|
function _inviteByMethod(inviteMethod) {
|
||||||
|
|||||||
Reference in New Issue
Block a user