add support for user and document fixtures
This commit is contained in:
parent
ec8a7b9228
commit
e56cd9cf80
2 changed files with 35 additions and 14 deletions
|
|
@ -2,32 +2,53 @@ import seeder from '@cleverbeagle/seeder';
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import Documents from '../../api/Documents/Documents';
|
||||
|
||||
const documentsSeed = userId => ({
|
||||
collection: Documents,
|
||||
environments: ['development', 'staging'],
|
||||
noLimit: true,
|
||||
modelCount: 5,
|
||||
model(dataIndex) {
|
||||
return {
|
||||
owner: userId,
|
||||
title: `Document #${dataIndex + 1}`,
|
||||
body: `This is the body of document #${dataIndex + 1}`,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
seeder(Meteor.users, {
|
||||
environments: ['development', 'staging'],
|
||||
noLimit: true,
|
||||
data: [{
|
||||
email: 'admin@admin.com',
|
||||
password: 'password',
|
||||
profile: {
|
||||
name: {
|
||||
first: 'George',
|
||||
last: 'Clooney',
|
||||
first: 'Andy',
|
||||
last: 'Warhol',
|
||||
},
|
||||
},
|
||||
roles: ['admin'],
|
||||
data(userId) {
|
||||
return documentsSeed(userId);
|
||||
},
|
||||
}],
|
||||
});
|
||||
|
||||
seeder(Documents, {
|
||||
environments: ['development', 'staging'],
|
||||
wipe: true,
|
||||
min: 10,
|
||||
modelCount: 5,
|
||||
model(index, faker) {
|
||||
const owner = Meteor.users.findOne({ 'emails.address': 'admin@admin.com' })._id;
|
||||
const documentNumber = index + 1;
|
||||
const userCount = index + 1;
|
||||
return {
|
||||
owner,
|
||||
title: `${faker.lorem.words(5)} #${documentNumber}`,
|
||||
body: `This is the body of example document #${documentNumber}.`,
|
||||
email: `user+${userCount}@test.com`,
|
||||
password: 'password',
|
||||
profile: {
|
||||
name: {
|
||||
first: faker.name.firstName(),
|
||||
last: faker.name.lastName(),
|
||||
},
|
||||
},
|
||||
roles: ['user'],
|
||||
data(userId) {
|
||||
return documentsSeed(userId);
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@cleverbeagle/dates": "^0.2.0",
|
||||
"@cleverbeagle/seeder": "^0.3.0",
|
||||
"@cleverbeagle/seeder": "^1.1.0",
|
||||
"babel-runtime": "^6.20.0",
|
||||
"bcrypt": "^1.0.2",
|
||||
"jquery": "^2.2.4",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue