Mock namespaces in mirage

This commit is contained in:
Michael Lange 2017-10-10 09:36:36 -07:00
parent ef55cb910f
commit bf8d9f05b1
2 changed files with 4 additions and 3 deletions

View file

@ -9,13 +9,13 @@ export function findLeader(schema) {
}
export default function() {
this.timing = 200; // delay for each request, automatically set to 0 during testing
this.timing = 0; // delay for each request, automatically set to 0 during testing
this.namespace = 'v1';
this.get('/jobs', function({ jobs }) {
const json = this.serialize(jobs.all());
return json.map(job => filterKeys(job, 'TaskGroups'));
return json.map(job => filterKeys(job, 'TaskGroups', 'NamespaceID'));
});
this.get('/job/:id');

View file

@ -1,5 +1,5 @@
import { Factory, faker } from 'ember-cli-mirage';
import { provide, provider } from '../utils';
import { provide, provider, pickOne } from '../utils';
import { DATACENTERS } from '../common';
const JOB_PREFIXES = provide(5, faker.hacker.abbreviation);
@ -50,6 +50,7 @@ export default Factory.extend({
job.update({
taskGroupIds: groups.mapBy('id'),
task_group_ids: groups.mapBy('id'),
namespaceId: server.db.namespaces.length && pickOne(server.db.namespaces).id,
});
const jobSummary = server.create('job-summary', {