mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
* fix #12124
add a transaction for updating user and group
so the user doesn't lose gems when saving the group fails
* use mongoose transaction helper
use the helper instead of manually commiting/aborting
to deal with transient transaction errors
* increase timeout and add console.log outputs
add some logging to a failing test
* Revert "increase timeout and add console.log outputs"
This reverts commit 0c36aaa55f.
* add a test for gems when guild creation fails
test the transaction in createGroup()
make sure user keeps the gems if group.save() rejects
* fix(test): try suggested delay from PR discussion
Co-authored-by: SabreCat <sabe@habitica.com>
This commit is contained in:
committed by
GitHub
parent
9a3e3c93eb
commit
1823f658c6
@@ -219,11 +219,19 @@ describe('GET /groups', () => {
|
||||
|
||||
it('returns 30 guilds per page ordered by number of members', async () => {
|
||||
await user.update({ balance: 9000 });
|
||||
const groups = await Promise.all(_.times(60, i => generateGroup(user, {
|
||||
name: `public guild ${i} - is member`,
|
||||
type: 'guild',
|
||||
privacy: 'public',
|
||||
})));
|
||||
const delay = () => new Promise(resolve => setTimeout(resolve, 40));
|
||||
const promises = [];
|
||||
|
||||
for (let i = 0; i < 60; i += 1) {
|
||||
promises.push(generateGroup(user, {
|
||||
name: `public guild ${i} - is member`,
|
||||
type: 'guild',
|
||||
privacy: 'public',
|
||||
}));
|
||||
await delay(); // eslint-disable-line no-await-in-loop
|
||||
}
|
||||
|
||||
const groups = await Promise.all(promises);
|
||||
|
||||
// update group number 32 and not the first to make sure sorting works
|
||||
await groups[32].update({ name: 'guild with most members', memberCount: 199 });
|
||||
|
||||
Reference in New Issue
Block a user