Fix API early Stat Point allocation (#10680)

* Refactor hasClass check to common so it can be used in shared & server-side code

* Check that user has selected class before allocating stat points
This commit is contained in:
Carl Vuorinen
2018-09-21 17:55:55 +03:00
committed by Matteo Pagliazzi
parent 26c8323e70
commit 71c0939a15
11 changed files with 204 additions and 7 deletions

View File

@@ -8,7 +8,11 @@ describe('POST /user/allocate', () => {
let user;
beforeEach(async () => {
user = await generateUser();
user = await generateUser({
'stats.lvl': 10,
'flags.classSelected': true,
'preferences.disableClasses': false,
});
});
// More tests in common code unit tests
@@ -31,6 +35,16 @@ describe('POST /user/allocate', () => {
});
});
it('returns an error if the user hasn\'t selected class', async () => {
await user.update({'flags.classSelected': false});
await expect(user.post('/user/allocate'))
.to.eventually.be.rejected.and.eql({
code: 401,
error: 'NotAuthorized',
message: t('classNotSelected'),
});
});
it('allocates attribute points', async () => {
await user.update({'stats.points': 1});
let res = await user.post('/user/allocate?stat=con');