mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
Members: user .lean() to improve performances (#10399)
* perf(members): use lean where possible * fix unit tests * fix unit tests and update calls to old function * simplify code and add tests
This commit is contained in:
@@ -7,6 +7,9 @@ import {
|
||||
questActivityWebhook,
|
||||
userActivityWebhook,
|
||||
} from '../../../../../website/server/libs/webhook';
|
||||
import {
|
||||
model as User,
|
||||
} from '../../../../../website/server/models/user';
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../../../helpers/api-unit.helper.js';
|
||||
@@ -306,17 +309,6 @@ describe('webhooks', () => {
|
||||
return this;
|
||||
},
|
||||
},
|
||||
addComputedStatsToJSONObj () {
|
||||
let mockStats = Object.assign({
|
||||
maxHealth: 50,
|
||||
maxMP: 103,
|
||||
toNextLevel: 40,
|
||||
}, this.stats);
|
||||
|
||||
delete mockStats.toJSON;
|
||||
|
||||
return mockStats;
|
||||
},
|
||||
},
|
||||
task: {
|
||||
text: 'text',
|
||||
@@ -324,6 +316,15 @@ describe('webhooks', () => {
|
||||
direction: 'up',
|
||||
delta: 176,
|
||||
};
|
||||
|
||||
let mockStats = Object.assign({
|
||||
maxHealth: 50,
|
||||
maxMP: 103,
|
||||
toNextLevel: 40,
|
||||
}, data.user.stats);
|
||||
delete mockStats.toJSON;
|
||||
|
||||
sandbox.stub(User, 'addComputedStatsToJSONObj').returns(mockStats);
|
||||
});
|
||||
|
||||
it('sends task and stats data', () => {
|
||||
|
||||
Reference in New Issue
Block a user