Last active
July 18, 2017 18:20
-
-
Save e00dan/f7756fe0198f7275ac41a6a786947aaa to your computer and use it in GitHub Desktop.
PromiseObjectIsPendingTemplate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default function () { | |
window.server = this; | |
this.timing = 3000; | |
this.get('/categories'); | |
this.get('/categories/:id'); | |
this.get('/posts'); | |
this.get('/posts/:id'); | |
this.get('/words'); | |
this.get('/words/:id'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Factory, faker } from 'ember-cli-mirage'; | |
export default Factory.extend({ | |
name(i) { | |
return `Category ${i+1}`; | |
}, | |
description: 'This is the description', | |
afterCreate(category, server) { | |
server.createList('post', 5, { category }); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Factory, association } from 'ember-cli-mirage'; | |
export default Factory.extend({ | |
name(i) { | |
return `Post ${i+1}`; | |
}, | |
afterCreate(post, server) { | |
let qty = Math.floor(Math.random() * 10) + 3 ; | |
server.createList('word', qty, { post }); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Factory, faker, association } from 'ember-cli-mirage'; | |
export default Factory.extend({ | |
text(i) { | |
return faker.random.word(); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Model, hasMany } from 'ember-cli-mirage'; | |
export default Model.extend({ | |
posts: hasMany() | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Model, hasMany, belongsTo } from 'ember-cli-mirage'; | |
export default Model.extend({ | |
category: belongsTo(), | |
words: hasMany() | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Model, belongsTo } from 'ember-cli-mirage'; | |
export default Model.extend({ | |
post: belongsTo() | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function(server) { | |
//let category = server.create('category'); | |
//server.createList('post', 10, { category }); | |
server.createList('category', 5); | |
//server.createList('post', 4); | |
//server.createList('word', 10); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DS from 'ember-data'; | |
export default DS.Model.extend({ | |
name: DS.attr('string'), | |
description: DS.attr('string'), | |
posts: DS.hasMany('post'), | |
urgentPosts: Ember.computed.filterBy('posts', 'isUrgent'), | |
postsLoading: Ember.computed.filterBy('posts', 'isLoading'), | |
isUrgent: Ember.computed.gt('urgentPosts.length', 0) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DS from 'ember-data'; | |
export default DS.Model.extend({ | |
name: DS.attr('string'), | |
category: DS.belongsTo('category'), | |
words: DS.hasMany('word'), | |
status: 'notUrgent', | |
//status: 'urgent', | |
isUrgent: Ember.computed.equal('status', 'urgent') | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DS from 'ember-data'; | |
export default DS.Model.extend({ | |
post: DS.belongsTo('post'), | |
text: DS.attr('string') | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('home', {path: '/'}); | |
this.route('categories', {path: 'categories'}); | |
this.route('category', {path: 'category/:id'}); | |
this.route('posts', {path: 'posts'}); | |
this.route('post', {path: 'post/:id'}); | |
}); | |
export default Router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
beforeModel() { | |
this.transitionTo('/category/1'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model() { | |
return this.store.findAll('category'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model(params) { | |
return this.store.findRecord('category', params.id); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model(params) { | |
return this.store.findRecord('post', params.id); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model() { | |
return this.store.findAll('post'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.12.1", | |
"ENV": { | |
"ember-cli-mirage": { | |
"enabled": true | |
} | |
}, | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js", | |
"ember": "2.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "2.13.2", | |
"ember-cli-mirage": "0.3.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment