feat: Mock accounts in mirage

This commit is contained in:
Susmitha Girumala committed 2020-09-14 11:26:54 -04:00
1 parent cf5a625740
commit 879989a127
6 files changed
+48 -2

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
import factory from '../generated/factories/account';
export default factory.extend();
+15 -1
View File
@@ -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(),
});
+8
View File
@@ -0,0 +1,8 @@
import { Model, belongsTo } from 'ember-cli-mirage';
export default Model.extend({
scope: belongsTo(),
authMethod: belongsTo()
});
+1 -1
View File
@@ -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');
+5
View File
@@ -0,0 +1,5 @@
import ApplicationSerializer from './application';
export default ApplicationSerializer.extend({
modelName: 'account'
});