💚
This commit is contained in:
@ -86,8 +86,9 @@ const uploadAvatar = async model => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Team.prototype.provisionSubdomain = async function(subdomain) {
|
Team.prototype.provisionSubdomain = async function(subdomain) {
|
||||||
let append = 0;
|
if (this.subdomain) return this.subdomain;
|
||||||
|
|
||||||
|
let append = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
await this.update({ subdomain });
|
await this.update({ subdomain });
|
||||||
@ -97,6 +98,7 @@ Team.prototype.provisionSubdomain = async function(subdomain) {
|
|||||||
subdomain = `${subdomain}${++append}`;
|
subdomain = `${subdomain}${++append}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return subdomain;
|
return subdomain;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,8 +12,17 @@ it('should set subdomain if available', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should set subdomain with append if unavailable', async () => {
|
it('should set subdomain with append if unavailable', async () => {
|
||||||
const team = await buildTeam({ subdomain: 'myteam' });
|
await buildTeam({ subdomain: 'myteam' });
|
||||||
|
|
||||||
|
const team = await buildTeam();
|
||||||
const subdomain = await team.provisionSubdomain('myteam');
|
const subdomain = await team.provisionSubdomain('myteam');
|
||||||
expect(subdomain).toEqual('myteam1');
|
expect(subdomain).toEqual('myteam1');
|
||||||
expect(team.subdomain).toEqual('myteam1');
|
expect(team.subdomain).toEqual('myteam1');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should do nothing if subdomain already set', async () => {
|
||||||
|
const team = await buildTeam({ subdomain: 'example' });
|
||||||
|
const subdomain = await team.provisionSubdomain('myteam');
|
||||||
|
expect(subdomain).toEqual('example');
|
||||||
|
expect(team.subdomain).toEqual('example');
|
||||||
|
});
|
||||||
|
Reference in New Issue
Block a user