feat: Mock accounts in mirage
This commit is contained in:
6 files changed
+48
-2
No files matched your search
@@ -0,0 +1,3 @@
|
||||
import factory from '../generated/factories/account';
|
||||
|
||||
export default factory.extend();
|
||||
@@ -1,3 +1,17 @@
|
||||
import factory from '../generated/factories/auth-method';
|
||||
import { trait } from 'ember-cli-mirage';
|
||||
|
||||
export default factory.extend();
|
||||
export default factory.extend({
|
||||
id: (i) => `auth-method-id-${i}`
|
||||
|
||||
/**
|
||||
* Adds accounts.
|
||||
*/
|
||||
withAccounts: trait({
|
||||
afterCreate(authMethod, server) {
|
||||
const { scope } = authMethod;
|
||||
server.createList('account', 5, { scope });
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
import { Factory } from 'ember-cli-mirage';
|
||||
import { random, date } from 'faker';
|
||||
|
||||
/**
|
||||
* GeneratedAccountFactory
|
||||
*/
|
||||
export default Factory.extend({
|
||||
|
||||
type: 'password',
|
||||
name: () => random.words(),
|
||||
description: () => random.words(),
|
||||
created_time: () => date.recent(),
|
||||
updated_time: () => date.recent(),
|
||||
version: () => random.number(),
|
||||
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
import { Model, belongsTo } from 'ember-cli-mirage';
|
||||
|
||||
export default Model.extend({
|
||||
|
||||
scope: belongsTo(),
|
||||
authMethod: belongsTo()
|
||||
|
||||
});
|
||||
@@ -15,7 +15,7 @@ export default function(server) {
|
||||
|
||||
// Auth
|
||||
server.createList('auth-method', 3, { scope: globalScope });
|
||||
server.createList('auth-method', 3, { scope: orgScope });
|
||||
server.createList('auth-method', 3, { scope: orgScope }, 'withAccounts');
|
||||
|
||||
// Groups and Users
|
||||
server.createList('group', 5, { scope: orgScope }, 'withMembers');
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
modelName: 'account'
|
||||
});
|
||||
Reference in new issue
Block a user