diff --git a/ui/core/mirage/factories/account.js b/ui/core/mirage/factories/account.js new file mode 100644 index 000000000..5908d0a21 --- /dev/null +++ b/ui/core/mirage/factories/account.js @@ -0,0 +1,3 @@ +import factory from '../generated/factories/account'; + +export default factory.extend(); diff --git a/ui/core/mirage/factories/auth-method.js b/ui/core/mirage/factories/auth-method.js index aa15a1103..8c75d95df 100644 --- a/ui/core/mirage/factories/auth-method.js +++ b/ui/core/mirage/factories/auth-method.js @@ -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 }); + } + }) + +}); diff --git a/ui/core/mirage/generated/factories/account.js b/ui/core/mirage/generated/factories/account.js new file mode 100644 index 000000000..a53c6aefe --- /dev/null +++ b/ui/core/mirage/generated/factories/account.js @@ -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(), + +}); diff --git a/ui/core/mirage/models/account.js b/ui/core/mirage/models/account.js new file mode 100644 index 000000000..e6d3e303c --- /dev/null +++ b/ui/core/mirage/models/account.js @@ -0,0 +1,8 @@ +import { Model, belongsTo } from 'ember-cli-mirage'; + +export default Model.extend({ + + scope: belongsTo(), + authMethod: belongsTo() + +}); diff --git a/ui/core/mirage/scenarios/default.js b/ui/core/mirage/scenarios/default.js index 1524a7647..9492f92e3 100644 --- a/ui/core/mirage/scenarios/default.js +++ b/ui/core/mirage/scenarios/default.js @@ -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'); diff --git a/ui/core/mirage/serializers/account.js b/ui/core/mirage/serializers/account.js new file mode 100644 index 000000000..3a5f8ae35 --- /dev/null +++ b/ui/core/mirage/serializers/account.js @@ -0,0 +1,5 @@ +import ApplicationSerializer from './application'; + +export default ApplicationSerializer.extend({ + modelName: 'account' +});