mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 14:17:22 +01:00
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:
committed by
Matteo Pagliazzi
parent
26c8323e70
commit
71c0939a15
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user