Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5043-mock_Date
This commit is contained in:
commit
c990b9a564
|
@ -47,44 +47,32 @@ module.exports = function(Self) {
|
|||
}
|
||||
|
||||
try {
|
||||
const promises = [];
|
||||
|
||||
if (args.deletes) {
|
||||
for (const itemTagId of args.deletes) {
|
||||
const itemTagDeleted = models.ItemTag.destroyById(itemTagId, myOptions);
|
||||
promises.push(itemTagDeleted);
|
||||
}
|
||||
for (const itemTagId of args.deletes)
|
||||
await models.ItemTag.destroyById(itemTagId, myOptions);
|
||||
}
|
||||
|
||||
if (args.updates) {
|
||||
for (const row of args.updates) {
|
||||
if (row.data.priority) {
|
||||
const itemTag = await models.ItemTag.findById(row.where.id, null, myOptions);
|
||||
const itemTagUpdatedPriority = itemTag.updateAttributes({
|
||||
await itemTag.updateAttributes({
|
||||
priority: row.data.priority + args.maxPriority
|
||||
}, myOptions);
|
||||
promises.push(itemTagUpdatedPriority);
|
||||
}
|
||||
}
|
||||
for (const row of args.updates) {
|
||||
const itemTag = await models.ItemTag.findById(row.where.id, null, myOptions);
|
||||
const itemTagUpdated = itemTag.updateAttributes(row.data, myOptions);
|
||||
promises.push(itemTagUpdated);
|
||||
await itemTag.updateAttributes(row.data, myOptions);
|
||||
}
|
||||
}
|
||||
|
||||
if (args.creates) {
|
||||
for (const itemTag of args.creates) {
|
||||
const newItemTag = models.ItemTag.create(itemTag, myOptions);
|
||||
promises.push(newItemTag);
|
||||
for (const itemTag of args.creates)
|
||||
await models.ItemTag.create(itemTag, myOptions);
|
||||
}
|
||||
}
|
||||
|
||||
const resolvedPromises = await Promise.all(promises);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return resolvedPromises;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
|
|
|
@ -12,9 +12,8 @@ describe('tag onSubmit()', () => {
|
|||
deletes: deletes
|
||||
}
|
||||
};
|
||||
const result = await models.Tag.onSubmit(ctx, options);
|
||||
await models.Tag.onSubmit(ctx, options);
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
@ -33,9 +32,8 @@ describe('tag onSubmit()', () => {
|
|||
updates: updates
|
||||
}
|
||||
};
|
||||
const result = await models.Tag.onSubmit(ctx, options);
|
||||
await models.Tag.onSubmit(ctx, options);
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
@ -62,9 +60,8 @@ describe('tag onSubmit()', () => {
|
|||
creates: creates
|
||||
}
|
||||
};
|
||||
const result = await models.Tag.onSubmit(ctx, options);
|
||||
await models.Tag.onSubmit(ctx, options);
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
@ -88,9 +85,8 @@ describe('tag onSubmit()', () => {
|
|||
|
||||
}
|
||||
};
|
||||
const result = await models.Tag.onSubmit(ctx, options);
|
||||
await models.Tag.onSubmit(ctx, options);
|
||||
|
||||
expect(result.length).toEqual(4);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
|
Loading…
Reference in New Issue