0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Data generator: Ensure user roles are only generated if roles already exist

no issue

Fixes the build, as in the test environment there are no user roles
This commit is contained in:
Sam Lord 2023-02-20 11:06:14 +00:00
parent d6f1e51dd6
commit 70e2c07f2e

View file

@ -20,9 +20,14 @@ class RolesUsersImporter extends TableImporter {
min: 0,
max: userRoles.length - 1
})];
const actualRole = this.roles.find(role => role.name === userRole);
if (!actualRole) {
// No roles defined in database, don't bother creating user role
return;
}
return {
id: faker.database.mongodbObjectId(),
role_id: this.roles.find(role => role.name === userRole).id,
role_id: actualRole.id,
user_id: this.model.id
};
}