Commit 4bf7ae7a authored by Bertrand PINEL's avatar Bertrand PINEL

Introduction of Mirage for rack objects

parent a60672d1
import Ember from 'ember';
import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr('string'),
nbColumns: DS.attr('number'),
nbRows: DS.attr('number'),
image: DS.attr('string'),
createdAt: DS.attr('date', {defaultValue() { return new Date(); }}),
capacity: Ember.computed('nbColumns', 'nbRows', function() {
return this.get('nbColumns')*this.get('nbRows'); }),
});
export default function() {
// this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server
// this.namespace = ''; // make this `api`, for example, if your API is namespaced
// this.timing = 400; // delay for each request, automatically set to 0 during testing
/*
Shorthand cheatsheet:
this.get('/posts');
this.post('/posts');
this.get('/posts/:id');
this.put('/posts/:id'); // or this.patch
this.del('/posts/:id');
http://www.ember-cli-mirage.com/docs/v0.2.x/shorthands/
*/
this.namespace = 'api';
this.get('/racks', function(schema) {
return schema.racks.all();
});
}
import { Factory, faker } from 'ember-cli-mirage';
export default Factory.extend({
name(i) { return 'rack number '+i; },
nbColumns() { return faker.random.number({min:4, max:12}); },
nbRows() { return faker.random.number({min:3, max:20}); },
image() { return './img/rack_0'+faker.random.number({min:1, max:5})+'.jpg';}
});
import { Model } from 'ember-cli-mirage';
export default Model.extend({
});
export default function(server) {
/*
Seed your development database using your factories.
This data will not be loaded in your tests.
Make sure to define a factory for each model you want to create.
*/
// server.createList('post', 10);
server.createList('rack', 32);
}
import { JSONAPISerializer } from 'ember-cli-mirage';
export default JSONAPISerializer.extend({
});
......@@ -2,4 +2,7 @@ import Ember from 'ember';
export default function destroyApp(application) {
Ember.run(application, 'destroy');
if(window.server) {
window.server.shutdown();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment