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:
parent
d6f1e51dd6
commit
70e2c07f2e
1 changed files with 6 additions and 1 deletions
|
@ -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
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue